From 9ac74d50814b474432357b0213e6bcdff8c67bac Mon Sep 17 00:00:00 2001 From: Valentin Haenel Date: Thu, 11 Mar 2021 17:01:56 +0100 Subject: [PATCH] fix failed refactoring The PR #103 introduced some failed refactorings regarding testing of Numpy arrays. This fixes that. --- test/test_numpy_io.py | 67 ++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 42 deletions(-) diff --git a/test/test_numpy_io.py b/test/test_numpy_io.py index 47693bc6..7757eecc 100644 --- a/test/test_numpy_io.py +++ b/test/test_numpy_io.py @@ -87,50 +87,42 @@ def test_unpack_exception(): sink = CompressedFPSink(sio) pack(source, sink, *calculate_nchunks(len(a_str))) with pytest.raises(NotANumpyArray): - unpack_ndarray_from_bytes, sio.getvalue() + unpack_ndarray_from_bytes(sio.getvalue()) -def roundtrip_ndarray(ndarray): - roundtrip_numpy_memory(ndarray) - roundtrip_numpy_str(ndarray) - roundtrip_numpy_file_pointers(ndarray) - roundtrip_numpy_file(ndarray) +def roundtrip_ndarray(a): + roundtrip_numpy_memory(a) + roundtrip_numpy_str(a) + roundtrip_numpy_file_pointers(a) + roundtrip_numpy_file(a) def test_numpy_dtypes_shapes_order(): # happy trail a = np.arange(50) - for case in roundtrip_ndarray(a): - case() + roundtrip_ndarray(a) for dt in np.sctypes['int'] + np.sctypes['uint'] + np.sctypes['float']: a = np.arange(64, dtype=dt) - for case in roundtrip_ndarray(a): - case() + roundtrip_ndarray(a) a = a.copy().reshape(8, 8) - for case in roundtrip_ndarray(a): - case() + roundtrip_ndarray(a) a = a.copy().reshape(4, 16) - for case in roundtrip_ndarray(a): - case() + roundtrip_ndarray(a) a = a.copy().reshape(4, 4, 4) - for case in roundtrip_ndarray(a): - case() + roundtrip_ndarray(a) a = np.asfortranarray(a) assert np.isfortran(a) - for case in roundtrip_ndarray(a): - case() + roundtrip_ndarray(a) # Fixed width string arrays a = np.array(['abc', 'def', 'ghi']) - for case in roundtrip_ndarray(a): - case() + roundtrip_ndarray(a) # This actually get's cast to a fixed width string array a = np.array([(1, 'abc'), (2, 'def'), (3, 'ghi')]) - for case in roundtrip_ndarray(a): - case() + roundtrip_ndarray(a) ## object arrays #a = np.array([(1, 'abc'), (2, 'def'), (3, 'ghi')], dtype='object') @@ -139,16 +131,14 @@ def test_numpy_dtypes_shapes_order(): # structured array a = np.array([('a', 1), ('b', 2)], dtype=[('a', 'S1'), ('b', 'f8')]) - for case in roundtrip_ndarray(a): - case() + roundtrip_ndarray(a) # record array a = np.array([(1, 'O', 1)], dtype=np.dtype([('step', 'int32'), ('symbol', '|S1'), ('index', 'int32')])) - for case in roundtrip_ndarray(a): - case() + roundtrip_ndarray(a) # and a nested record array dt = [('year', '