diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2014-11-30 12:14:12 -0500 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2014-11-30 12:14:12 -0500 |
commit | 665e52e8460cfb2e75e91bd70a60c813033fd8ed (patch) | |
tree | 09367d2f6882c568e698f88b838ce4bd37aff2c7 | |
parent | 8993a5d07b0fba2968b4cb0d61489ae86da001bf (diff) | |
parent | 359118160365672554d576b3d6b341e907135133 (diff) | |
download | numpy-665e52e8460cfb2e75e91bd70a60c813033fd8ed.tar.gz |
Merge pull request #5326 from cournape/fix_hashable_collections
BUG: fix collections.Hashable behaviour for numpy arrays.
-rw-r--r-- | numpy/core/src/multiarray/arrayobject.c | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 8 |
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() |