def test_encode(): dtype = 'i8' astype = 'i4' codec = Delta(dtype=dtype, astype=astype) arr = np.arange(10, 20, 1, dtype=dtype) expect = np.array([10] + ([1] * 9), dtype=astype) actual = codec.encode(arr) assert_array_equal(expect, actual) eq(np.dtype(astype), actual.dtype)
def test_backwards_compatibility(): for arr in arrays: codec = Delta(dtype=arr.dtype) check_backwards_compatibility(Delta.codec_id, [arr], [codec], prefix=str(arr.dtype))
def test_config(): codec = Delta(dtype='<i4', astype='<i2') check_config(codec)
def test_encode_decode(): for arr in arrays: codec = Delta(dtype=arr.dtype) check_encode_decode(arr, codec)
def test_errors(): with pytest.raises(ValueError): Delta(dtype=object) with pytest.raises(ValueError): Delta(dtype='i8', astype=object)