Hydration
Functions to be able to make sending and recreating autopilot objects by sending compressed representations of their instantiation.
Examples
>>> import autopilot
>>> from pprint import pprint
>>> Noise = autopilot.get('sound', 'Noise')
>>> a_noise = Noise(duration=1000, amplitude=0.01, fs=44100)
>>> dehydrated_noise = dehydrate(a_noise)
>>> pprint(dehydrated_noise)
{'class': 'autopilot.stim.sound.sounds.Noise',
'kwargs': {'amplitude': 0.01,
'channel': None,
'duration': 1000,
'fs': 44100}}
>>> b_noise = hydrate(dehydrated_noise)
>>> a_noise
<autopilot.stim.sound.sounds.Noise object at 0x12d76f400>
>>> b_noise
<autopilot.stim.sound.sounds.Noise object at 0x12d690310>
>>> a_noise._introspect['__init__']
{'fs': 44100, 'duration': 1000, 'amplitude': 0.01, 'channel': None}
>>> b_noise._introspect['__init__']
{'fs': 44100, 'duration': 1000, 'amplitude': 0.01, 'channel': None}
Functions:
|
Get a dehydrated version of an object that has its |
|
Rehydrate an object description from |
- dehydrate(obj) dict [source]
- Get a dehydrated version of an object that has its
__init__
method wrapped with utils.decorators.Introspect
for sending across the wire/easier reinstantiation and provenance.
- Get a dehydrated version of an object that has its
- hydrate(obj_dict: dict)[source]
Rehydrate an object description from
dehydrate()