def test_backwards_compat(): def old_ndarray_meta(ndarray): # This DOESN'T use 'repr', see also: # bloscpack.numpy_io._ndarray_meta return { 'dtype': ndarray.dtype.descr if ndarray.dtype.names is not None else ndarray.dtype.str, 'shape': ndarray.shape, 'order': 'F' if np.isfortran(ndarray) else 'C', 'container': 'numpy', } test_data = [ np.arange(10), np.array([('a', 1), ('b', 2)], dtype=[('a', 'S1'), ('b', 'f8')]), ] with mock.patch('bloscpack.numpy_io._ndarray_meta', old_ndarray_meta): for a in test_data: # uses old version of _ndarray_meta c = pack_ndarray_str(a) # should not raise a SyntaxError d = unpack_ndarray_str(c) yield npt.assert_array_equal, a, d
def test_backwards_compat(): import bloscpack import numpy def old_ndarray_meta(ndarray): # This DOESN'T use 'repr', see also: # bloscpack.numpy_io._ndarray_meta return {'dtype': ndarray.dtype.descr if ndarray.dtype.names is not None else ndarray.dtype.str, 'shape': ndarray.shape, 'order': 'F' if numpy.isfortran(ndarray) else 'C', 'container': 'numpy', } a = np.arange(10) with mock.patch('bloscpack.numpy_io._ndarray_meta', old_ndarray_meta): # uses old version of _ndarray_meta c = pack_ndarray_str(a) # should not raise a SyntaxError d = unpack_ndarray_str(c)
def test_backwards_compat(): def old_ndarray_meta(ndarray): # This DOESN'T use 'repr', see also: # bloscpack.numpy_io._ndarray_meta return {'dtype': ndarray.dtype.descr if ndarray.dtype.names is not None else ndarray.dtype.str, 'shape': ndarray.shape, 'order': 'F' if np.isfortran(ndarray) else 'C', 'container': 'numpy', } test_data = [np.arange(10), np.array([('a', 1), ('b', 2)], dtype=[('a', 'S1'), ('b', 'f8')]), ] with mock.patch('bloscpack.numpy_io._ndarray_meta', old_ndarray_meta): for a in test_data: # uses old version of _ndarray_meta c = pack_ndarray_str(a) # should not raise a SyntaxError d = unpack_ndarray_str(c) yield npt.assert_array_equal, a, d
def roundtrip_numpy_str(ndarray): s = pack_ndarray_str(ndarray) b = unpack_ndarray_str(s) return npt.assert_array_equal, ndarray, b
def test_roundtrip_numpy_str(self): s = pack_ndarray_str(self.a) b = unpack_ndarray_str(s) npt.assert_array_equal(self.a, b)