def test_to_binary_roundtrip_3d(tmpdir, eng): a = arange(16, dtype='int16').reshape((4, 2, 2)) p = str(tmpdir) + '/data' data = fromarray(a, npartitions=1, engine=eng) data.tobinary(p) loaded = frombinary(p, engine=eng) assert allclose(data.toarray(), loaded.toarray())
def test_from_binary(tmpdir, eng): a = arange(8, dtype='int16').reshape((4, 2)) p = os.path.join(str(tmpdir), 'data.bin') a.tofile(p) data = frombinary(p, shape=[4, 2], dtype='int16', engine=eng) assert allclose(data.shape, (4, 2)) assert allclose(data.index, [0, 1]) assert allclose(data.toarray(), a)
def test_from_binary_skip(tmpdir, eng): k = [[i] for i in range(10)] v = [[0, i] for i in range(10)] a = array([kv[0] + kv[1] for kv in zip(k, v)], dtype='int16') p = os.path.join(str(tmpdir), 'data.bin') a.tofile(p) data = frombinary(p, shape=[10, 2], dtype='int16', skip=1, engine=eng) assert allclose(data.shape, (10, 2)) assert allclose(data.index, [0, 1]) assert allclose(data.toarray(), v)