diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-11-19 23:30:31 -0800 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2018-11-19 23:30:31 -0800 |
commit | 8b366e0b0fff8bd46397d4d013832efce6e338b1 (patch) | |
tree | 25468b3153c4f931e6b2038ff730e1e656a6f0d3 /numpy/tests | |
parent | 1466e788a43b8d4356fe35951bf0c3b0aedb554f (diff) | |
download | numpy-8b366e0b0fff8bd46397d4d013832efce6e338b1.tar.gz |
BUG: Fix inconsistent cache keying in ndpointer
Fixes an alarming bug introduced in gh-7311 (1.12) where the following is true
np.ctypeslib.ndpointer(ndim=2) is np.ctypeslib.ndpointer(shape=2)
Rework of gh-11536
Diffstat (limited to 'numpy/tests')
-rw-r--r-- | numpy/tests/test_ctypeslib.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/numpy/tests/test_ctypeslib.py b/numpy/tests/test_ctypeslib.py index 675f8d242..a6d73b152 100644 --- a/numpy/tests/test_ctypeslib.py +++ b/numpy/tests/test_ctypeslib.py @@ -108,9 +108,14 @@ class TestNdpointer(object): assert_raises(TypeError, p.from_param, np.array([[1, 2], [3, 4]])) def test_cache(self): - a1 = ndpointer(dtype=np.float64) - a2 = ndpointer(dtype=np.float64) - assert_(a1 == a2) + assert_(ndpointer(dtype=np.float64) is ndpointer(dtype=np.float64)) + + # shapes are normalized + assert_(ndpointer(shape=2) is ndpointer(shape=(2,))) + + # 1.12 <= v < 1.16 had a bug that made these fail + assert_(ndpointer(shape=2) is not ndpointer(ndim=2)) + assert_(ndpointer(ndim=2) is not ndpointer(shape=2)) @pytest.mark.skipif(not _HAS_CTYPE, |