openmmtools.utils.serialize¶
- openmmtools.utils.serialize(instance, **kwargs)[source]¶
Serialize an object.
The object must expose a __getstate__ method that returns a dictionary representation of its state. This will be passed to __setstate__ for deserialization. The function automatically handle the resolution of the correct class.
- Parameters:
- instanceobject
An instance of a new style class.
- kwargsKeyword arguments which are passed onto the __getstate__ function.
- If you implement your own class with a __getstate__ method, have it accept **kwargs and then manipulate
them inside the __getstate__ method itself.
These are primarily optimization settings and will not normally be publicly documented because they can fundamentally change how the “state” of an object is returned.
- Returns:
- serializationdict
A dictionary representation of the object that can be stored in several formats (e.g. JSON, YAML, HDF5) and reconstructed into the original object with deserialize().