deserialize#
- pymc_extras.deserialize.deserialize(data: Any) Any[source]#
Deserialize a dictionary into a Python object.
Use the
register_deserialization()function to add custom deserializations.Deserialization is a two step process due to the dynamic nature of the data:
Determine if the data is of the correct type.
Deserialize the data into a Python object.
Each registered deserialization is checked in order until one is found that can deserialize the data. If no deserialization is found, a
DeserializableErroris raised.A
DeserializableErroris raised when the data fails to be deserialized by any of the registered deserializers.- Parameters:
data (Any) – The data to deserialize.
- Returns:
The deserialized object.
- Return type:
Any
- Raises:
DeserializableError – Raised when the data doesn’t match any registered deserializations or fails to be deserialized.
Examples
Deserialize a
pymc_extras.prior.Priorobject:from pymc_extras.deserialize import deserialize data = {"dist": "Normal", "kwargs": {"mu": 0, "sigma": 1}} prior = deserialize(data) # Prior("Normal", mu=0, sigma=1)