8.4.2.5. pymodaq_utils.serialize.utils module

pymodaq_utils.serialize.utils.bytes_to_int(bytes_string)[source]

Convert a bytes of length 4 into an integer

Return type:

int

pymodaq_utils.serialize.utils.bytes_to_nd_array(data, dtype, shape)[source]

Convert bytes to a ndarray given a certain numpy dtype and shape

Parameters:
Return type:

ndarray

pymodaq_utils.serialize.utils.bytes_to_scalar(data, dtype)[source]

Convert bytes to a scalar given a certain numpy dtype

Parameters:
  • data (bytes)

  • dtype (dtype)

Return type:

complex

pymodaq_utils.serialize.utils.bytes_to_string(message)[source]
Return type:

str

pymodaq_utils.serialize.utils.get_int_from_bytes(bytes_str)[source]

Convert the 4 first bytes into an integer

Return type:

Tuple[int, bytes]

Returns:

  • int (the decoded integer)

  • bytes (the remaining bytes string if any)

pymodaq_utils.serialize.utils.int_to_bytes(an_integer)[source]

Convert an unsigned integer into a byte array of length 4 in big endian

Parameters:

an_integer (int)

Return type:

bytes

pymodaq_utils.serialize.utils.split_nbytes(bytes_str, bytes_len)[source]
Return type:

Tuple[bytes, bytes]

pymodaq_utils.serialize.utils.str_len_to_bytes(message)[source]

Convert a string and its length to two bytes :param message: the message to convert :type message: Union[str, bytes]

Return type:

Tuple[bytes, bytes]

Returns:

  • bytes (message converted as a byte array)

  • bytes (length of the message byte array, itself as a byte array of length 4)

pymodaq_utils.serialize.utils.str_to_bytes(message)[source]
Return type:

bytes