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))
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))
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))
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)
def test_compress_memoryview(): mv = memoryview(b"0" * 1000000) compression, compressed = maybe_compress(mv) if compression: assert len(compressed) < len(mv)
def test_compress_numpy(): x = np.ones(10000000, dtype='i4') compression, compressed = maybe_compress(x.data) if compression: assert len(compressed) < x.nbytes
def test_compress_memoryview(): mv = memoryview(b'0' * 1000000) compression, compressed = maybe_compress(mv) if compression: assert len(compressed) < len(mv)