8.4.2.3. pymodaq_utils.serialize.serializer module
Created the 20/10/2023
@author: Sebastien Weber
- class pymodaq_utils.serialize.serializer.BytesSerializeDeserialize[source]
Bases:
SerializableBaseMethods
deserialize(bytes_str)serialize(some_bytes)
- class pymodaq_utils.serialize.serializer.DictSerializeDeserialize[source]
Bases:
SerializableBaseMethods
deserialize(bytes_str)Convert bytes into a dictionary of serializable objects
serialize(dict_object)Convert a dictionnary of objects into a bytes message together with the info to convert it back
- static deserialize(bytes_str)[source]
Convert bytes into a dictionary of serializable objects
Convert the first bytes into a dict reading first information about the key elts of the dictionnary then the underlying objects …
- static serialize(dict_object)[source]
Convert a dictionnary of objects into a bytes message together with the info to convert it back
- Parameters:
dict_object (
dict[Union[None,bytes,str,int,float,complex,list,tuple,dict,ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]],SerializableBase],Union[None,bytes,str,int,float,complex,list,tuple,dict,ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]],SerializableBase]]) – the dict could contain whatever objects are registered in the SerializableFactory- Returns:
bytes
- Return type:
Notes
The bytes sequence is constructed as: * the list of keys of the dict
Then for each key: * use the serialization method adapted to the object inferred from the key
- class pymodaq_utils.serialize.serializer.ListSerializeDeserialize[source]
Bases:
SerializableBaseMethods
deserialize(bytes_str)Convert bytes into a list of objects
serialize(list_object)Convert a list of objects into a bytes message together with the info to convert it back
- static deserialize(bytes_str)[source]
Convert bytes into a list of objects
Convert the first bytes into a list reading first information about the list elt types, length …
- static serialize(list_object)[source]
Convert a list of objects into a bytes message together with the info to convert it back
- Parameters:
list_object (
List) – the list could contain whatever objects are registered in the SerializableFactory- Returns:
bytes
- Return type:
Notes
The bytes sequence is constructed as: * the length of the list
Then for each object: * use the serialization method adapted to each object in the list
- class pymodaq_utils.serialize.serializer.NdArraySerializeDeserialize[source]
Bases:
SerializableBaseMethods
deserialize(bytes_str)Convert bytes into a numpy ndarray object
serialize(array)Convert a ndarray into a bytes message together with the info to convert it back
- static deserialize(bytes_str)[source]
Convert bytes into a numpy ndarray object
Convert the first bytes into a ndarray reading first information about the array’s data
- static serialize(array)[source]
Convert a ndarray into a bytes message together with the info to convert it back
- Parameters:
array (
ndarray)- Returns:
bytes
- Return type:
Notes
The bytes sequence is constructed as:
get data type as a string
reshape array as 1D array and get the array dimensionality (len of array’s shape)
convert Data array as bytes
serialize data type
serialize data length
serialize data shape length
serialize all values of the shape as integers converted to bytes
serialize array as bytes
- class pymodaq_utils.serialize.serializer.NoneSerializeDeserialize[source]
Bases:
SerializableBaseMethods
deserialize(bytes_str)serialize(obj)
- class pymodaq_utils.serialize.serializer.ScalarSerializeDeserialize[source]
Bases:
SerializableBaseMethods
deserialize(bytes_str)Convert bytes into a python object of type (float, int, complex or boolean)
serialize(scalar)Convert a scalar into a bytes message together with the info to convert it back
- class pymodaq_utils.serialize.serializer.SerializableTypes(*values)[source]
Bases:
EnumType names of serializable types
- ARRAY = 'array'
- AXIS = 'axis'
- BOOL = 'bool'
- BYTES = 'bytes'
- DATA_TO_EXPORT = 'dte'
- DATA_WITH_AXES = 'dwa'
- DICT = 'dict'
- LIST = 'list'
- NONE = 'NoneType'
- PARAMETER = 'parameter'
- SCALAR = 'scalar'
- STRING = 'string'
- TUPLE = 'tuple'
- class pymodaq_utils.serialize.serializer.StringSerializeDeserialize[source]
Bases:
SerializableBaseMethods
deserialize(bytes_str)Convert bytes into a str object
serialize(string)Convert a string into a bytes message together with the info to convert it back
- class pymodaq_utils.serialize.serializer.TupleSerializeDeserialize[source]
Bases:
SerializableBaseMethods
deserialize(bytes_str)Convert bytes into a tuple of objects
serialize(tuple_object)Convert a tuple of objects into a bytes message together with the info to convert it back
- static deserialize(bytes_str)[source]
Convert bytes into a tuple of objects
Convert the first bytes into a tuple reading first information about the tuple elt types, length …
- static serialize(tuple_object)[source]
Convert a tuple of objects into a bytes message together with the info to convert it back
- Parameters:
tuple_object (
Tuple[Union[None,bytes,str,int,float,complex,list,tuple,dict,ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]],SerializableBase],...]) – the tuple could contain whatever objects are registered in the SerializableFactory- Returns:
bytes
- Return type:
Notes
The bytes sequence is constructed as: * the length of the tuple
Then for each object: * use the serialization method adapted to each object in the tuple