deserialize#
- pymc_marketing.deserialize.deserialize(data)[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
DeserializableError
is raised.A
DeserializableError
is raised when the data fails to be deserialized by any of the registered deserializers.- Parameters:
- data
Any
The data to deserialize.
- data
- Returns:
Any
The deserialized object.
- Raises:
DeserializableError
Raised when the data doesn’t match any registered deserializations or fails to be deserialized.
Examples
Deserialize a
pymc_marketing.prior.Prior
object:from pymc_marketing.deserialize import deserialize data = {"dist": "Normal", "kwargs": {"mu": 0, "sigma": 1}} prior = deserialize(data) # Prior("Normal", mu=0, sigma=1)