@@ -2,11 +2,10 @@ import ctypes as ct
22from typing_extensions import LiteralString , assert_type
33
44import numpy as np
5- from numpy .dtypes import StringDType
65
76dtype_U : np .dtype [np .str_ ]
87dtype_V : np .dtype [np .void ]
9- dtype_i8 : np .dtype [ np . int64 ]
8+ dtype_i8 : np .dtypes . Int64DType
109
1110py_int_co : type [int ]
1211py_float_co : type [float ]
@@ -19,30 +18,30 @@ ct_floating: type[ct.c_float | ct.c_double | ct.c_longdouble]
1918ct_number : type [ct .c_uint8 | ct .c_float ]
2019ct_generic : type [ct .c_bool | ct .c_char ]
2120
22- dt_string : StringDType
21+ dt_string : np . dtypes . StringDType
2322
24- assert_type (np .dtype (np .float64 ), np .dtype [ np . float64 ] )
25- assert_type (np .dtype (np .float64 , metadata = {"test" : "test" }), np .dtype [ np . float64 ] )
26- assert_type (np .dtype (np .int64 ), np .dtype [ np . int64 ] )
23+ assert_type (np .dtype (np .float64 ), np .dtypes . Float64DType )
24+ assert_type (np .dtype (np .float64 , metadata = {"test" : "test" }), np .dtypes . Float64DType )
25+ assert_type (np .dtype (np .int64 ), np .dtypes . Int64DType )
2726
2827# String aliases
29- assert_type (np .dtype ("bool" ), np .dtype [ np . bool ] )
30- assert_type (np .dtype ("int32" ), np .dtype [ np . int32 ] )
31- assert_type (np .dtype ("int64" ), np .dtype [ np . int64 ] )
32- assert_type (np .dtype ("float32" ), np .dtype [ np . float32 ] )
33- assert_type (np .dtype ("float64" ), np .dtype [ np . float64 ] )
34- assert_type (np .dtype ("bytes" ), np .dtype [ np . bytes_ ] )
35- assert_type (np .dtype ("str" ), np .dtype [ np . str_ ] )
28+ assert_type (np .dtype ("bool" ), np .dtypes . BoolDType )
29+ assert_type (np .dtype ("int32" ), np .dtypes . Int32DType )
30+ assert_type (np .dtype ("int64" ), np .dtypes . Int64DType )
31+ assert_type (np .dtype ("float32" ), np .dtypes . Float32DType )
32+ assert_type (np .dtype ("float64" ), np .dtypes . Float64DType )
33+ assert_type (np .dtype ("bytes" ), np .dtypes . BytesDType )
34+ assert_type (np .dtype ("str" ), np .dtypes . StrDType )
3635
3736# Python types
38- assert_type (np .dtype (bool ), np .dtype [ np . bool ] )
39- assert_type (np .dtype (int ), np .dtype [ np . int_ ] )
40- assert_type (np .dtype (float ), np .dtype [ np . float64 ] )
41- assert_type (np .dtype (complex ), np .dtype [ np . complex128 ] )
42- assert_type (np .dtype (object ), np .dtype [ np . object_ ] )
43- assert_type (np .dtype (str ), np .dtype [ np . str_ ] )
44- assert_type (np .dtype (bytes ), np .dtype [ np . bytes_ ] )
45- assert_type (np .dtype (memoryview ), np .dtype [ np . void ] )
37+ assert_type (np .dtype (bool ), np .dtypes . BoolDType )
38+ assert_type (np .dtype (int ), np .dtypes . Int64DType )
39+ assert_type (np .dtype (float ), np .dtypes . Float64DType )
40+ assert_type (np .dtype (complex ), np .dtypes . Complex128DType )
41+ assert_type (np .dtype (object ), np .dtypes . ObjectDType )
42+ assert_type (np .dtype (str ), np .dtypes . StrDType )
43+ assert_type (np .dtype (bytes ), np .dtypes . BytesDType )
44+ assert_type (np .dtype (memoryview ), np .dtypes . VoidDType )
4645
4746assert_type (np .dtype (np .signedinteger ), np .dtype [np .signedinteger ])
4847assert_type (np .dtype (np .unsignedinteger ), np .dtype [np .unsignedinteger ])
@@ -55,37 +54,37 @@ assert_type(np.dtype(np.number), np.dtype[np.number])
5554assert_type (np .dtype (np .generic ), np .dtype [np .generic ])
5655
5756# char-codes
58- assert_type (np .dtype ("u1" ), np .dtype [ np . uint8 ] )
59- assert_type (np .dtype ("int_" ), np .dtype [ np . intp ] )
60- assert_type (np .dtype ("longlong" ), np .dtype [ np . longlong ] )
61- assert_type (np .dtype (">g" ), np .dtype [ np . longdouble ] )
57+ assert_type (np .dtype ("u1" ), np .dtypes . UInt8DType )
58+ assert_type (np .dtype ("int_" ), np .dtypes . Int64DType )
59+ assert_type (np .dtype ("longlong" ), np .dtypes . Int64DType )
60+ assert_type (np .dtype (">g" ), np .dtypes . LongDoubleDType )
6261
6362# ctypes
64- assert_type (np .dtype (ct .c_bool ), np .dtype [ np . bool ] )
65- assert_type (np .dtype (ct .c_uint32 ), np .dtype [ np . uint32 ] )
66- assert_type (np .dtype (ct .c_ssize_t ), np .dtype [ np . intp ] )
67- assert_type (np .dtype (ct .c_longlong ), np .dtype [ np . longlong ] )
68- assert_type (np .dtype (ct .c_double ), np .dtype [ np . double ] )
69- assert_type (np .dtype (ct .py_object ), np .dtype [ np . object_ ] )
70- assert_type (np .dtype (ct .c_char ), np .dtype [ np . bytes_ ] )
63+ assert_type (np .dtype (ct .c_bool ), np .dtypes . BoolDType )
64+ assert_type (np .dtype (ct .c_uint32 ), np .dtypes . UInt32DType )
65+ assert_type (np .dtype (ct .c_ssize_t ), np .dtypes . Int64DType )
66+ assert_type (np .dtype (ct .c_longlong ), np .dtypes . Int64DType )
67+ assert_type (np .dtype (ct .c_double ), np .dtypes . Float64DType )
68+ assert_type (np .dtype (ct .py_object ), np .dtypes . ObjectDType )
69+ assert_type (np .dtype (ct .c_char ), np .dtypes . BytesDType )
7170
7271# Special case for None
73- assert_type (np .dtype (None ), np .dtype [ np . float64 ] )
72+ assert_type (np .dtype (None ), np .dtypes . Float64DType )
7473
7574# Dypes of dtypes
76- assert_type (np .dtype (np .dtype (np .float64 )), np .dtype [ np . float64 ] )
75+ assert_type (np .dtype (np .dtype (np .float64 )), np .dtypes . Float64DType )
7776
7877# Parameterized dtypes
7978assert_type (np .dtype ("S8" ), np .dtype )
8079
8180# Void
82- assert_type (np .dtype (("U" , 10 )), np .dtype [ np . void ] )
81+ assert_type (np .dtype (("U" , 10 )), np .dtypes . VoidDType )
8382
8483# StringDType
85- assert_type (np .dtype (dt_string ), StringDType )
86- assert_type (np .dtype ("T" ), StringDType )
87- assert_type (np .dtype ("=T" ), StringDType )
88- assert_type (np .dtype ("|T" ), StringDType )
84+ assert_type (np .dtype (dt_string ), np . dtypes . StringDType )
85+ assert_type (np .dtype ("T" ), np . dtypes . StringDType )
86+ assert_type (np .dtype ("=T" ), np . dtypes . StringDType )
87+ assert_type (np .dtype ("|T" ), np . dtypes . StringDType )
8988
9089# Methods and attributes
9190assert_type (dtype_U .base , np .dtype )
@@ -100,7 +99,7 @@ assert_type(dtype_U * 1, np.dtype[np.str_])
10099assert_type (dtype_U * 2 , np .dtype [np .str_ ])
101100
102101assert_type (dtype_i8 * 0 , np .dtype [np .void ])
103- assert_type (dtype_i8 * 1 , np .dtype [ np . int64 ] )
102+ assert_type (dtype_i8 * 1 , np .dtypes . Int64DType )
104103assert_type (dtype_i8 * 2 , np .dtype [np .void ])
105104
106105assert_type (0 * dtype_U , np .dtype [np .str_ ])
0 commit comments