pathsim.utils.serialization module

pathsim.utils.serialization.serialize_callable(func)[source]

Serialize a callable with priority for human-readable formats

Parameters:

func (callable) – function to serialize into dict

Returns:

serialized function

Return type:

dict

pathsim.utils.serialization.serialize_object(obj)[source]

Serialize any object by capturing its module and class

Parameters:

obj (object) – object to serialize into dict

Returns:

serialized object

Return type:

dict

pathsim.utils.serialization.deserialize(data)[source]

Deserialize an object from dictionary representation

Parameters:

data (dict) – dict to deserialize into object

Returns:

python object recovered from dict

Return type:

object

class pathsim.utils.serialization.Serializable[source]

Bases: object

Mixin that provides automatic serialization based on __init__ parameters and loading/saving to json formatted readable files

save(path='')[source]

Save the dictionary representation of object to an external file

Parameters:

path (str) – filepath to save data to

classmethod load(path='')[source]

Load and instantiate an object from an external file in json format

Parameters:

path (str) – filepath to load data from

Returns:

out – reconstructed object from dict representation

Return type:

obj

to_dict()[source]

Convert object to dictionary representation

Returns:

result – representation of object

Return type:

dict

classmethod from_dict(data)[source]

Create block instance from dictionary representation.

Parameters:

data (dict) – representation of object

Returns:

out – reconstructed object from dict representation

Return type:

obj