diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-08-01 18:08:57 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-08-05 21:50:05 -0500 |
commit | dda20349d172ed09b949a3b819eb16a384cd29a8 (patch) | |
tree | ea92f1f5f6147f3532c3dc833d6fa28677cd5519 /numpy | |
parent | 0ab1a2b12baabe3bd7063e2963c83482a4f57016 (diff) | |
download | numpy-dda20349d172ed09b949a3b819eb16a384cd29a8.tar.gz |
BUG: abstract types did not compare correctly with issubdtype
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/numerictypes.py | 6 | ||||
-rw-r--r-- | numpy/core/tests/test_numerictypes.py | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index 136081412..e7e7e5509 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -751,14 +751,16 @@ def issubdtype(arg1, arg2): False """ + if not issubclass_(arg1, generic): + arg1 = dtype(arg1).type if issubclass_(arg2, generic): - return issubclass(dtype(arg1).type, arg2) + return issubclass(arg1, arg2) mro = dtype(arg2).type.mro() if len(mro) > 1: val = mro[1] else: val = mro[0] - return issubclass(dtype(arg1).type, val) + return issubclass(arg1, val) # This dictionary allows look up based on any alias for an array data-type diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py index f912e3944..977e4ce40 100644 --- a/numpy/core/tests/test_numerictypes.py +++ b/numpy/core/tests/test_numerictypes.py @@ -377,5 +377,12 @@ class TestMultipleFields(object): res = self.ary[['f0', 'f2']].tolist() assert_(res == [(1, 3), (5, 7)]) + +class TestIsSubDType(object): + def test_both_abstract(self): + assert_(np.issubdtype(np.floating, np.inexact)) + assert_(not np.issubdtype(np.inexact, np.floating)) + + if __name__ == "__main__": run_module_suite() |