diff options
author | Seth Troisi <sethtroisi@google.com> | 2020-01-07 17:04:09 -0800 |
---|---|---|
committer | Seth Troisi <sethtroisi@google.com> | 2020-01-07 18:15:51 -0800 |
commit | 97d57790de7e63133b0dee67f1d4c9db581e7b09 (patch) | |
tree | 5d3aeb263d62168707d8b0fb211efd0ccf2da117 /numpy | |
parent | f31ce546045ccb765ef0992b9c841d4682eee775 (diff) | |
download | numpy-97d57790de7e63133b0dee67f1d4c9db581e7b09.tar.gz |
MAINT: Simplify np.int_ inheritance
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarray/multiarraymodule.c | 25 | ||||
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 4 |
2 files changed, 3 insertions, 26 deletions
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index f3dbfe0d6..b1b9c0051 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -4216,15 +4216,6 @@ setup_scalartypes(PyObject *NPY_UNUSED(dict)) return -1; \ } -/* - * In Py3K, int is no longer a fixed-width integer type, so don't - * inherit numpy.int_ from it. - */ -#define INHERIT_INT(child, parent2) \ - SINGLE_INHERIT(child, parent2); - -#define DUAL_INHERIT_COMPARE(child, parent1, parent2) - #define DUAL_INHERIT2(child, parent1, parent2) \ Py##child##ArrType_Type.tp_base = &Py##parent1##_Type; \ Py##child##ArrType_Type.tp_bases = \ @@ -4232,7 +4223,6 @@ setup_scalartypes(PyObject *NPY_UNUSED(dict)) &Py##parent2##ArrType_Type); \ Py##child##ArrType_Type.tp_richcompare = \ Py##parent1##_Type.tp_richcompare; \ - DUAL_INHERIT_COMPARE(child, parent1, parent2) \ Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash; \ if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \ PyErr_Print(); \ @@ -4245,20 +4235,9 @@ setup_scalartypes(PyObject *NPY_UNUSED(dict)) SINGLE_INHERIT(Bool, Generic); SINGLE_INHERIT(Byte, SignedInteger); SINGLE_INHERIT(Short, SignedInteger); - -#if NPY_SIZEOF_INT == NPY_SIZEOF_LONG - INHERIT_INT(Int, SignedInteger); -#else SINGLE_INHERIT(Int, SignedInteger); -#endif - - INHERIT_INT(Long, SignedInteger); - -#if NPY_SIZEOF_LONGLONG == NPY_SIZEOF_LONG - INHERIT_INT(LongLong, SignedInteger); -#else + SINGLE_INHERIT(Long, SignedInteger); SINGLE_INHERIT(LongLong, SignedInteger); -#endif /* Datetime doesn't fit in any category */ SINGLE_INHERIT(Datetime, Generic); @@ -4297,9 +4276,7 @@ setup_scalartypes(PyObject *NPY_UNUSED(dict)) #undef SINGLE_INHERIT #undef DUAL_INHERIT -#undef INHERIT_INT #undef DUAL_INHERIT2 -#undef DUAL_INHERIT_COMPARE /* * Clean up string and unicode array types so they act more like diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 0eae49239..85910886a 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -346,8 +346,8 @@ class TestAttributes: numpy_int = np.int_(0) - # int_ doesn't inherit from Python int, because it is not fixed width - assert_equal(isinstance(numpy_int, int), False) + # int_ doesn't inherit from Python int, because it's not fixed-width + assert_(not isinstance(numpy_int, int)) def test_stridesattr(self): x = self.one |