How to use the blosc.blosc_extension.decompress function in blosc

To help you get started, we’ve selected a few blosc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Blosc / python-blosc / blosc / toplevel.py View on Github external
>>> 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
github Blosc / c-blosc2 / python / blosc / toplevel.py View on Github external
>>> 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)
github Blosc / python-blosc / blosc / toplevel.py View on Github external
>>> 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)