Example #1
0
def test_compression_takes_advantage_of_itemsize():
    blosc = pytest.importorskip('blosc')
    x = np.arange(1000000, dtype='i8')

    assert (len(blosc.compress(x.data, typesize=8))
          < len(blosc.compress(x.data, typesize=1)))

    _, a = serialize(x)
    aa = [maybe_compress(frame)[1] for frame in a]
    _, b = serialize(x.view('u1'))
    bb = [maybe_compress(frame)[1] for frame in b]

    assert sum(map(nbytes, aa)) < sum(map(nbytes, bb))
Example #2
0
def test_compression_takes_advantage_of_itemsize():
    pytest.importorskip("lz4")
    blosc = pytest.importorskip("blosc")
    x = np.arange(1000000, dtype="i8")

    assert len(blosc.compress(x.data, typesize=8)) < len(
        blosc.compress(x.data, typesize=1))

    _, a = serialize(x)
    aa = [maybe_compress(frame)[1] for frame in a]
    _, b = serialize(x.view("u1"))
    bb = [maybe_compress(frame)[1] for frame in b]

    assert sum(map(nbytes, aa)) < sum(map(nbytes, bb))
Example #3
0
def test_compression_takes_advantage_of_itemsize():
    pytest.importorskip('lz4')
    blosc = pytest.importorskip('blosc')
    x = np.arange(1000000, dtype='i8')

    assert (len(blosc.compress(x.data, typesize=8))
            < len(blosc.compress(x.data, typesize=1)))

    _, a = serialize(x)
    aa = [maybe_compress(frame)[1] for frame in a]
    _, b = serialize(x.view('u1'))
    bb = [maybe_compress(frame)[1] for frame in b]

    assert sum(map(nbytes, aa)) < sum(map(nbytes, bb))
Example #4
0
        def _inplace_compress_frames(header, frames):
            compression = list(header.get("compression", [None] * len(frames)))

            for i in range(len(frames)):
                if compression[i] is None:
                    compression[i], frames[i] = maybe_compress(
                        frames[i], **compress_opts)

            header["compression"] = tuple(compression)
Example #5
0
def test_compress_memoryview():
    mv = memoryview(b"0" * 1000000)
    compression, compressed = maybe_compress(mv)
    if compression:
        assert len(compressed) < len(mv)
Example #6
0
def test_compress_numpy():
    x = np.ones(10000000, dtype='i4')
    compression, compressed = maybe_compress(x.data)
    if compression:
        assert len(compressed) < x.nbytes
Example #7
0
def test_compress_memoryview():
    mv = memoryview(b'0' * 1000000)
    compression, compressed = maybe_compress(mv)
    if compression:
        assert len(compressed) < len(mv)
Example #8
0
def test_compress_numpy():
    x = np.ones(10000000, dtype='i4')
    compression, compressed = maybe_compress(x.data)
    if compression:
        assert len(compressed) < x.nbytes