We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e4b6bfe + c441971 commit 17c17f5Copy full SHA for 17c17f5
3 files changed
.gitignore
@@ -128,12 +128,12 @@ ENV/
128
env.bak/
129
venv.bak/
130
131
-# Spyder project settings
+# Project settings
132
+.idea
133
+.ropeproject
134
.spyderproject
135
.spyproject
-
-# Rope project settings
136
-.ropeproject
+.vscode
137
138
# mkdocs documentation
139
/site
array_api_strict/_data_type_functions.py
@@ -167,6 +167,9 @@ def isdtype(
167
https://data-apis.org/array-api/latest/API_specification/generated/array_api.isdtype.html
168
for more details
169
"""
170
+ if not isinstance(dtype, _DType):
171
+ raise TypeError(f"'dtype' must be a dtype, not a {type(dtype)!r}")
172
+
173
if isinstance(kind, tuple):
174
# Disallow nested tuples
175
if any(isinstance(k, tuple) for k in kind):
array_api_strict/tests/test_data_type_functions.py
@@ -31,15 +31,17 @@ def test_can_cast(from_, to, expected):
31
def test_isdtype_strictness():
32
assert_raises(TypeError, lambda: isdtype(float64, 64))
33
assert_raises(ValueError, lambda: isdtype(float64, 'f8'))
34
35
assert_raises(TypeError, lambda: isdtype(float64, (('integral',),)))
+ assert_raises(TypeError, lambda: isdtype(float64, None))
36
+ assert_raises(TypeError, lambda: isdtype(np.float64, float64))
37
+ assert_raises(TypeError, lambda: isdtype(asarray(1.0), float64))
38
39
with assert_raises(TypeError), warnings.catch_warnings(record=True) as w:
40
warnings.simplefilter("always")
41
isdtype(float64, np.object_)
42
assert len(w) == 1
43
assert issubclass(w[-1].category, UserWarning)
44
- assert_raises(TypeError, lambda: isdtype(float64, None))
45
46
47
isdtype(float64, np.float64)
0 commit comments