util#

Utility functions! everyone’s favorite!

perceptivo.util.download(url: str, file_name: Union[pathlib.Path, str]) bool#

Download a file with a progress bar

Returns

True if nothing happened and its probs good, False otherwise

Return type

bool

References

https://gist.github.com/yanqd0/c13ed29e29432e3cf3e7c38467f42f51

perceptivo.util.pack_array(array) dict#
perceptivo.util.unpack_array(shape: tuple, dtype: numpy.dtype, array: bytes) numpy.ndarray#
perceptivo.util.serialize(array: Union[numpy.ndarray, Any]) Union[dict, Any]#

Serialization for use with msgpack.packb as default

Returns

dict like:

{
    '__numpy__': True,
    'shape': array.shape,
    'dtype': str(array.dtype),
    'array': array.data
}

perceptivo.util.deserialize(obj)#
perceptivo.util.msgpack_loads(msg)#

Wrapper of the msgpack

perceptivo.util.msgpack_dumps(msg, *, default=None)#