8000 BUG: issubdtype is inconsistent on types and dtypes by eric-wieser · Pull Request #9505 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: issubdtype is inconsistent on types and dtypes #9505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 6, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BUG: abstract types did not compare correctly with issubdtype
  • Loading branch information
eric-wieser committed Aug 6, 2017
commit dda20349d172ed09b949a3b819eb16a384cd29a8
6 changes: 4 additions & 2 deletions numpy/core/numerictypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions numpy/core/tests/test_numerictypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,5 +377,12 @@ def test_return(self):
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()
0