summaryrefslogtreecommitdiff
path: root/numpy/typing
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2020-12-09 17:30:55 +0100
committerBas van Beek <b.f.van.beek@vu.nl>2020-12-09 17:30:55 +0100
commitab4252d1ea4bca1d881a44376a693ca8c5a75c1b (patch)
treebc925b4c0bcab9cdfcc0139748b1710a9b269022 /numpy/typing
parentc9dc6784e67c28e56317e40b3d192bc2d2345ce4 (diff)
downloadnumpy-ab4252d1ea4bca1d881a44376a693ca8c5a75c1b.tar.gz
TST: Add new tests for `dtype` methods
Diffstat (limited to 'numpy/typing')
-rw-r--r--numpy/typing/tests/data/pass/dtype.py8
-rw-r--r--numpy/typing/tests/data/reveal/dtype.py8
2 files changed, 16 insertions, 0 deletions
diff --git a/numpy/typing/tests/data/pass/dtype.py b/numpy/typing/tests/data/pass/dtype.py
index cbae8c078..a97edc302 100644
--- a/numpy/typing/tests/data/pass/dtype.py
+++ b/numpy/typing/tests/data/pass/dtype.py
@@ -1,5 +1,7 @@
import numpy as np
+dtype_obj = np.dtype(np.str_)
+
np.dtype(dtype=np.int64)
np.dtype(int)
np.dtype("int")
@@ -33,3 +35,9 @@ class Test:
np.dtype(Test())
+
+# Methods and attributes
+dtype_obj.base
+dtype_obj.subdtype
+dtype_obj.newbyteorder()
+dtype_obj.type
diff --git a/numpy/typing/tests/data/reveal/dtype.py b/numpy/typing/tests/data/reveal/dtype.py
index d414f2c49..626a15270 100644
--- a/numpy/typing/tests/data/reveal/dtype.py
+++ b/numpy/typing/tests/data/reveal/dtype.py
@@ -1,5 +1,7 @@
import numpy as np
+dtype_obj: np.dtype[np.str_]
+
reveal_type(np.dtype(np.float64)) # E: numpy.dtype[numpy.floating[numpy.typing._64Bit]]
reveal_type(np.dtype(np.int64)) # E: numpy.dtype[numpy.signedinteger[numpy.typing._64Bit]]
@@ -31,3 +33,9 @@ reveal_type(np.dtype("S8")) # E: numpy.dtype
# Void
reveal_type(np.dtype(("U", 10))) # E: numpy.dtype[numpy.void]
+
+# Methods and attributes
+reveal_type(dtype_obj.base) # E: numpy.dtype[numpy.str_]
+reveal_type(dtype_obj.subdtype) # E: Union[Tuple[numpy.dtype[numpy.str_], builtins.tuple[builtins.int]], None]
+reveal_type(dtype_obj.newbyteorder()) # E: numpy.dtype[numpy.str_]
+reveal_type(dtype_obj.type) # E: Type[numpy.str_]