@@ -2,11 +2,10 @@ import ctypes as ct
2
2
from typing_extensions import LiteralString , assert_type
3
3
4
4
import numpy as np
5
- from numpy .dtypes import StringDType
6
5
7
6
dtype_U : np .dtype [np .str_ ]
8
7
dtype_V : np .dtype [np .void ]
9
- dtype_i8 : np .dtype [ np . int64 ]
8
+ dtype_i8 : np .dtypes . Int64DType
10
9
11
10
py_int_co : type [int ]
12
11
py_float_co : type [float ]
@@ -19,30 +18,30 @@ ct_floating: type[ct.c_float | ct.c_double | ct.c_longdouble]
19
18
ct_number : type [ct .c_uint8 | ct .c_float ]
20
19
ct_generic : type [ct .c_bool | ct .c_char ]
21
20
22
- dt_string : StringDType
21
+ dt_string : np . dtypes . StringDType
23
22
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 )
27
26
28
27
# 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 )
36
35
37
36
# 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 )
46
45
47
46
assert_type (np .dtype (np .signedinteger ), np .dtype [np .signedinteger ])
48
47
assert_type (np .dtype (np .unsignedinteger ), np .dtype [np .unsignedinteger ])
@@ -55,37 +54,37 @@ assert_type(np.dtype(np.number), np.dtype[np.number])
55
54
assert_type (np .dtype (np .generic ), np .dtype [np .generic ])
56
55
57
56
# 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 )
62
61
63
62
# 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 )
71
70
72
71
# Special case for None
73
- assert_type (np .dtype (None ), np .dtype [ np . float64 ] )
72
+ assert_type (np .dtype (None ), np .dtypes . Float64DType )
74
73
75
74
# 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 )
77
76
78
77
# Parameterized dtypes
79
78
assert_type (np .dtype ("S8" ), np .dtype )
80
79
81
80
# Void
82
- assert_type (np .dtype (("U" , 10 )), np .dtype [ np . void ] )
81
+ assert_type (np .dtype (("U" , 10 )), np .dtypes . VoidDType )
83
82
84
83
# 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 )
89
88
90
89
# Methods and attributes
91
90
assert_type (dtype_U .base , np .dtype )
@@ -100,7 +99,7 @@ assert_type(dtype_U * 1, np.dtype[np.str_])
100
99
assert_type (dtype_U * 2 , np .dtype [np .str_ ])
101
100
102
101
assert_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 )
104
103
assert_type (dtype_i8 * 2 , np .dtype [np .void ])
105
104
106
105
assert_type (0 * dtype_U , np .dtype [np .str_ ])
0 commit comments