-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
/
scalars.py
160 lines (132 loc) · 5.79 KB
/
scalars.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import sys
import numpy as np
b: np.bool_
u8: np.uint64
i8: np.int64
f8: np.float64
c8: np.complex64
c16: np.complex128
m: np.timedelta64
U: np.str_
S: np.bytes_
reveal_type(c8.real) # E: {float32}
reveal_type(c8.imag) # E: {float32}
reveal_type(c8.real.real) # E: {float32}
reveal_type(c8.real.imag) # E: {float32}
reveal_type(c8.itemsize) # E: int
reveal_type(c8.shape) # E: Tuple[]
reveal_type(c8.strides) # E: Tuple[]
reveal_type(c8.ndim) # E: Literal[0]
reveal_type(c8.size) # E: Literal[1]
reveal_type(c8.squeeze()) # E: {complex64}
reveal_type(c8.byteswap()) # E: {complex64}
reveal_type(c8.transpose()) # E: {complex64}
reveal_type(c8.dtype) # E: numpy.dtype[{complex64}]
reveal_type(c8.real) # E: {float32}
reveal_type(c16.imag) # E: {float64}
reveal_type(np.unicode_('foo')) # E: numpy.str_
reveal_type(np.str0('foo')) # E: numpy.str_
# Aliases
reveal_type(np.unicode_()) # E: numpy.str_
reveal_type(np.str0()) # E: numpy.str_
reveal_type(np.bool8()) # E: numpy.bool_
reveal_type(np.bytes0()) # E: numpy.bytes_
reveal_type(np.string_()) # E: numpy.bytes_
reveal_type(np.object0()) # E: numpy.object_
reveal_type(np.void0(0)) # E: numpy.void
reveal_type(np.byte()) # E: {byte}
reveal_type(np.short()) # E: {short}
reveal_type(np.intc()) # E: {intc}
reveal_type(np.intp()) # E: {intp}
reveal_type(np.int0()) # E: {intp}
reveal_type(np.int_()) # E: {int_}
reveal_type(np.longlong()) # E: {longlong}
reveal_type(np.ubyte()) # E: {ubyte}
reveal_type(np.ushort()) # E: {ushort}
reveal_type(np.uintc()) # E: {uintc}
reveal_type(np.uintp()) # E: {uintp}
reveal_type(np.uint0()) # E: {uintp}
reveal_type(np.uint()) # E: {uint}
reveal_type(np.ulonglong()) # E: {ulonglong}
reveal_type(np.half()) # E: {half}
reveal_type(np.single()) # E: {single}
reveal_type(np.double()) # E: {double}
reveal_type(np.float_()) # E: {double}
reveal_type(np.longdouble()) # E: {longdouble}
reveal_type(np.longfloat()) # E: {longdouble}
reveal_type(np.csingle()) # E: {csingle}
reveal_type(np.singlecomplex()) # E: {csingle}
reveal_type(np.cdouble()) # E: {cdouble}
reveal_type(np.complex_()) # E: {cdouble}
reveal_type(np.cfloat()) # E: {cdouble}
reveal_type(np.clongdouble()) # E: {clongdouble}
reveal_type(np.clongfloat()) # E: {clongdouble}
reveal_type(np.longcomplex()) # E: {clongdouble}
reveal_type(b.item()) # E: bool
reveal_type(i8.item()) # E: int
reveal_type(u8.item()) # E: int
reveal_type(f8.item()) # E: float
reveal_type(c16.item()) # E: complex
reveal_type(U.item()) # E: str
reveal_type(S.item()) # E: bytes
reveal_type(b.tolist()) # E: bool
reveal_type(i8.tolist()) # E: int
reveal_type(u8.tolist()) # E: int
reveal_type(f8.tolist()) # E: float
reveal_type(c16.tolist()) # E: complex
reveal_type(U.tolist()) # E: str
reveal_type(S.tolist()) # E: bytes
reveal_type(b.ravel()) # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]
reveal_type(i8.ravel()) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(u8.ravel()) # E: numpy.ndarray[Any, numpy.dtype[{uint64}]]
reveal_type(f8.ravel()) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(c16.ravel()) # E: numpy.ndarray[Any, numpy.dtype[{complex128}]]
reveal_type(U.ravel()) # E: numpy.ndarray[Any, numpy.dtype[numpy.str_]]
reveal_type(S.ravel()) # E: numpy.ndarray[Any, numpy.dtype[numpy.bytes_]]
reveal_type(b.flatten()) # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]
reveal_type(i8.flatten()) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(u8.flatten()) # E: numpy.ndarray[Any, numpy.dtype[{uint64}]]
reveal_type(f8.flatten()) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(c16.flatten()) # E: numpy.ndarray[Any, numpy.dtype[{complex128}]]
reveal_type(U.flatten()) # E: numpy.ndarray[Any, numpy.dtype[numpy.str_]]
reveal_type(S.flatten()) # E: numpy.ndarray[Any, numpy.dtype[numpy.bytes_]]
reveal_type(b.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]
reveal_type(i8.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(u8.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[{uint64}]]
reveal_type(f8.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(c16.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[{complex128}]]
reveal_type(U.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[numpy.str_]]
reveal_type(S.reshape(1)) # E: numpy.ndarray[Any, numpy.dtype[numpy.bytes_]]
reveal_type(i8.astype(float)) # E: Any
reveal_type(i8.astype(np.float64)) # E: {float64}
reveal_type(i8.view()) # E: {int64}
reveal_type(i8.view(np.float64)) # E: {float64}
reveal_type(i8.view(float)) # E: Any
reveal_type(i8.view(np.float64, np.ndarray)) # E: {float64}
reveal_type(i8.getfield(float)) # E: Any
reveal_type(i8.getfield(np.float64)) # E: {float64}
reveal_type(i8.getfield(np.float64, 8)) # E: {float64}
reveal_type(f8.as_integer_ratio()) # E: Tuple[builtins.int, builtins.int]
reveal_type(f8.is_integer()) # E: bool
reveal_type(f8.__trunc__()) # E: int
reveal_type(f8.__getformat__("float")) # E: str
reveal_type(f8.hex()) # E: str
reveal_type(np.float64.fromhex("0x0.0p+0")) # E: {float64}
reveal_type(f8.__getnewargs__()) # E: Tuple[builtins.float]
reveal_type(c16.__getnewargs__()) # E: Tuple[builtins.float, builtins.float]
reveal_type(i8.numerator) # E: {int64}
reveal_type(i8.denominator) # E: Literal[1]
reveal_type(u8.numerator) # E: {uint64}
reveal_type(u8.denominator) # E: Literal[1]
reveal_type(m.numerator) # E: numpy.timedelta64
reveal_type(m.denominator) # E: Literal[1]
reveal_type(round(i8)) # E: int
reveal_type(round(i8, 3)) # E: {int64}
reveal_type(round(u8)) # E: int
reveal_type(round(u8, 3)) # E: {uint64}
reveal_type(round(f8)) # E: int
reveal_type(round(f8, 3)) # E: {float64}
if sys.version_info >= (3, 9):
reveal_type(f8.__ceil__()) # E: int
reveal_type(f8.__floor__()) # E: int
reveal_type(i8.is_integer()) # E: Literal[True]