summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel J. Smith <njs@pobox.com>2016-02-23 21:48:57 +0000
committerNathaniel J. Smith <njs@pobox.com>2016-02-23 21:48:57 +0000
commitade47293e641e64299de45172898ba03e907cb8d (patch)
treeeb64c94b73d2792921f4fe8ce8b5708e13bbf9e2
parentb3aa073c02c424ee67aed7c7e36b8bdb4e82a41f (diff)
parent141d3a954b955b7f0821574e03b693ec4078640b (diff)
downloadnumpy-ade47293e641e64299de45172898ba03e907cb8d.tar.gz
Merge pull request #7311 from udiboy1209/ndpointer_cache
[PATCH] Make _pointer_type_cache functional
-rw-r--r--numpy/ctypeslib.py2
-rw-r--r--numpy/tests/test_ctypeslib.py5
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()