summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-11-30 12:14:12 -0500
committerCharles Harris <charlesr.harris@gmail.com>2014-11-30 12:14:12 -0500
commit665e52e8460cfb2e75e91bd70a60c813033fd8ed (patch)
tree09367d2f6882c568e698f88b838ce4bd37aff2c7 /numpy
parent8993a5d07b0fba2968b4cb0d61489ae86da001bf (diff)
parent359118160365672554d576b3d6b341e907135133 (diff)
downloadnumpy-665e52e8460cfb2e75e91bd70a60c813033fd8ed.tar.gz
Merge pull request #5326 from cournape/fix_hashable_collections
BUG: fix collections.Hashable behaviour for numpy arrays.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/arrayobject.c2
-rw-r--r--numpy/core/tests/test_multiarray.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c
index 6f9c89082..3f91b748c 100644
--- a/numpy/core/src/multiarray/arrayobject.c
+++ b/numpy/core/src/multiarray/arrayobject.c
@@ -1769,7 +1769,7 @@ NPY_NO_EXPORT PyTypeObject PyArray_Type = {
&array_as_number, /* tp_as_number */
&array_as_sequence, /* tp_as_sequence */
&array_as_mapping, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
+ PyObject_HashNotImplemented, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)array_str, /* tp_str */
(getattrofunc)0, /* tp_getattro */
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 1e47a2297..fd3a0e13d 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -1,5 +1,6 @@
from __future__ import division, absolute_import, print_function
+import collections
import tempfile
import sys
import os
@@ -4848,5 +4849,12 @@ class TestSizeOf(TestCase):
assert_raises(TypeError, d.__sizeof__, "a")
+class TestHashing(TestCase):
+
+ def test_collections_hashable(self):
+ x = np.array([])
+ self.assertFalse(isinstance(x, collections.Hashable))
+
+
if __name__ == "__main__":
run_module_suite()