summaryrefslogtreecommitdiff
path: root/numpy/core/tests
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2020-03-21 23:59:47 -0500
committerGitHub <noreply@github.com>2020-03-22 00:59:47 -0400
commit1be88ff070cce6ac720804e861583682564f7e0d (patch)
tree24807be585128958e7257c7a0f364b562fe27b8e /numpy/core/tests
parent0b9b176dcef7f14f56dbd543c89e6da6c6b7b2e4 (diff)
downloadnumpy-1be88ff070cce6ac720804e861583682564f7e0d.tar.gz
DEP: Make issubdtype consistent for types and dtypes (#15773)
This finishes the deprecation started in gh-9505 removing behaviour that allowed strings/types representing specific dtypes to behave like their more generic supertypes (e.g. the python float would map to floating instead of float64 which it typically maps to). Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
Diffstat (limited to 'numpy/core/tests')
-rw-r--r--numpy/core/tests/test_numerictypes.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py
index dc3a821b9..9cb00342d 100644
--- a/numpy/core/tests/test_numerictypes.py
+++ b/numpy/core/tests/test_numerictypes.py
@@ -401,6 +401,35 @@ class TestIsSubDType:
assert_(not np.issubdtype(w1(np.float32), w2(np.float64)))
assert_(not np.issubdtype(w1(np.float64), w2(np.float32)))
+ def test_nondtype_nonscalartype(self):
+ # See gh-14619 and gh-9505 which introduced the deprecation to fix
+ # this. These tests are directly taken from gh-9505
+ assert not np.issubdtype(np.float32, 'float64')
+ assert not np.issubdtype(np.float32, 'f8')
+ assert not np.issubdtype(np.int32, str)
+ assert not np.issubdtype(np.int32, 'int64')
+ assert not np.issubdtype(np.str_, 'void')
+ # for the following the correct spellings are
+ # np.integer, np.floating, or np.complexfloating respectively:
+ assert not np.issubdtype(np.int8, int) # np.int8 is never np.int_
+ assert not np.issubdtype(np.float32, float)
+ assert not np.issubdtype(np.complex64, complex)
+ assert not np.issubdtype(np.float32, "float")
+ assert not np.issubdtype(np.float64, "f")
+
+ # Test the same for the correct first datatype and abstract one
+ # in the case of int, float, complex:
+ assert np.issubdtype(np.float64, 'float64')
+ assert np.issubdtype(np.float64, 'f8')
+ assert np.issubdtype(np.str_, str)
+ assert np.issubdtype(np.int64, 'int64')
+ assert np.issubdtype(np.void, 'void')
+ assert np.issubdtype(np.int8, np.integer)
+ assert np.issubdtype(np.float32, np.floating)
+ assert np.issubdtype(np.complex64, np.complexfloating)
+ assert np.issubdtype(np.float64, "float")
+ assert np.issubdtype(np.float32, "f")
+
class TestSctypeDict:
def test_longdouble(self):