diff options
-rw-r--r-- | numpy/ctypeslib.py | 2 | ||||
-rw-r--r-- | numpy/tests/test_ctypeslib.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/numpy/ctypeslib.py b/numpy/ctypeslib.py index fa1dcad6f..38173fba4 100644 --- a/numpy/ctypeslib.py +++ b/numpy/ctypeslib.py @@ -315,7 +315,7 @@ def ndpointer(dtype=None, ndim=None, shape=None, flags=None): "_shape_" : shape, "_ndim_" : ndim, "_flags_" : num}) - _pointer_type_cache[dtype] = klass + _pointer_type_cache[(dtype, shape, ndim, num)] = klass return klass if ctypes is not None: diff --git a/numpy/tests/test_ctypeslib.py b/numpy/tests/test_ctypeslib.py index 5e888eb65..36274ad46 100644 --- a/numpy/tests/test_ctypeslib.py +++ b/numpy/tests/test_ctypeslib.py @@ -101,6 +101,11 @@ class TestNdpointer(TestCase): self.assertTrue(p.from_param(x)) self.assertRaises(TypeError, p.from_param, np.array([[1, 2], [3, 4]])) + def test_cache(self): + a1 = ndpointer(dtype=np.float64) + a2 = ndpointer(dtype=np.float64) + self.assertEqual(a1, a2) + if __name__ == "__main__": run_module_suite() |