diff options
author | mattip <matti.picus@gmail.com> | 2018-11-09 14:28:44 -0800 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2018-11-13 06:38:22 -0800 |
commit | 1956ada852f950468e028cf108766e089f4575cc (patch) | |
tree | 3e048aa1f1f6aa985c0004ae38f48f9745701477 /numpy/lib/tests | |
parent | cd39348e8593dc2b41e2516fbdd8a69b0f0bda6e (diff) | |
download | numpy-1956ada852f950468e028cf108766e089f4575cc.tar.gz |
BUG: test, fix loading structured dtypes with padding
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test_format.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 3185e32ac..13a12197c 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -524,6 +524,26 @@ def test_compressed_roundtrip(): assert_array_equal(arr, arr1) +# aligned +dt1 = np.dtype('i1, i4, i1', align=True) +# non-aligned, explicit offsets +dt2 = np.dtype({'names': ['a', 'b'], 'formats': ['i4', 'i4'], + 'offsets': [1, 6]}) +# nested struct-in-struct +dt3 = np.dtype({'names': ['c', 'd'], 'formats': ['i4', dt2]}) +# field with '' name +dt4 = np.dtype({'names': ['a', '', 'b'], 'formats': ['i4']*3}) +@pytest.mark.parametrize("dt", [dt1, dt2, dt3, dt4]) +def test_load_padded_dtype(dt): + arr = np.zeros(3, dt) + for i in range(3): + arr[i] = i + 5 + npz_file = os.path.join(tempdir, 'aligned.npz') + np.savez(npz_file, arr=arr) + arr1 = np.load(npz_file)['arr'] + assert_array_equal(arr, arr1) + + def test_python2_python3_interoperability(): if sys.version_info[0] >= 3: fname = 'win64python2.npy' @@ -533,7 +553,6 @@ def test_python2_python3_interoperability(): data = np.load(path) assert_array_equal(data, np.ones(2)) - def test_pickle_python2_python3(): # Test that loading object arrays saved on Python 2 works both on # Python 2 and Python 3 and vice versa |