Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
>>> len(parray) < a.size*a.itemsize
True
>>> a2 = blosc.unpack_array(parray)
>>> numpy.alltrue(a == a2)
True
>>> a = numpy.array(['å', 'ç', 'ø'])
>>> parray = blosc.pack_array(a)
>>> a2 = blosc.unpack_array(parray)
>>> numpy.alltrue(a == a2)
True
"""
_check_bytesobj(packed_array)
# First decompress the pickle
pickled_array = _ext.decompress(packed_array, False)
# ... and unpickle
if kwargs and PY3X:
array = pickle.loads(pickled_array, **kwargs)
if all(isinstance(x, bytes) for x in array.tolist()):
import numpy
array = numpy.array([x.decode('utf-8') for x in array.tolist()])
else:
array = pickle.loads(pickled_array)
return array
>>> import array
>>> a = array.array('i', range(1000*1000))
>>> a_string = a.tostring()
>>> c_string = compress(a_string, typesize=4)
>>> a_string2 = decompress(c_string)
>>> a_string == a_string2
True
"""
if type(string) is not bytes:
raise ValueError(
"only string (2.x) or bytes (3.x) objects supported as input")
return _ext.decompress(string)
>>> a_bytesobj = a.tostring()
>>> c_bytesobj = blosc.compress(a_bytesobj, typesize=4)
>>> a_bytesobj2 = blosc.decompress(c_bytesobj)
>>> a_bytesobj == a_bytesobj2
True
>>> b"" == blosc.decompress(blosc.compress(b"", 1))
True
>>> b"1"*7 == blosc.decompress(blosc.compress(b"1"*7, 8))
True
>>> type(blosc.decompress(blosc.compress(b"1"*7, 8),
... as_bytearray=True)) is bytearray
True
"""
return _ext.decompress(bytesobj, as_bytearray)