@@ -12,14 +12,17 @@ def test_truediv_py_scalar() -> None:
12
12
"""Test pd.Series[float] / Python native scalars"""
13
13
b , i , f , c = True , 1 , 1.0 , 1j
14
14
15
+ check (assert_type (left / b , "pd.Series[float]" ), pd .Series , np .floating )
15
16
check (assert_type (left / i , "pd.Series[float]" ), pd .Series , np .floating )
16
17
check (assert_type (left / f , "pd.Series[float]" ), pd .Series , np .floating )
17
18
check (assert_type (left / c , "pd.Series[complex]" ), pd .Series , np .complexfloating )
18
19
20
+ check (assert_type (b / left , "pd.Series[float]" ), pd .Series , np .floating )
19
21
check (assert_type (i / left , "pd.Series[float]" ), pd .Series , np .floating )
20
22
check (assert_type (f / left , "pd.Series[float]" ), pd .Series , np .floating )
21
23
check (assert_type (c / left , "pd.Series[complex]" ), pd .Series , np .complexfloating )
22
24
25
+ check (assert_type (left .truediv (b ), "pd.Series[float]" ), pd .Series , np .floating )
23
26
check (assert_type (left .truediv (i ), "pd.Series[float]" ), pd .Series , np .floating )
24
27
check (assert_type (left .truediv (f ), "pd.Series[float]" ), pd .Series , np .floating )
25
28
check (
@@ -28,10 +31,12 @@ def test_truediv_py_scalar() -> None:
28
31
np .complexfloating ,
29
32
)
30
33
34
+ check (assert_type (left .div (b ), "pd.Series[float]" ), pd .Series , np .floating )
31
35
check (assert_type (left .div (i ), "pd.Series[float]" ), pd .Series , np .floating )
32
36
check (assert_type (left .div (f ), "pd.Series[float]" ), pd .Series , np .floating )
33
37
check (assert_type (left .div (c ), "pd.Series[complex]" ), pd .Series , np .complexfloating )
34
38
39
+ check (assert_type (left .rtruediv (b ), "pd.Series[float]" ), pd .Series , np .floating )
35
40
check (assert_type (left .rtruediv (i ), "pd.Series[float]" ), pd .Series , np .floating )
36
41
check (assert_type (left .rtruediv (f ), "pd.Series[float]" ), pd .Series , np .floating )
37
42
check (
@@ -40,6 +45,7 @@ def test_truediv_py_scalar() -> None:
40
45
np .complexfloating ,
41
46
)
42
47
48
+ check (assert_type (left .rdiv (b ), "pd.Series[float]" ), pd .Series , np .floating )
43
49
check (assert_type (left .rdiv (i ), "pd.Series[float]" ), pd .Series , np .floating )
44
50
check (assert_type (left .rdiv (f ), "pd.Series[float]" ), pd .Series , np .floating )
45
51
check (
@@ -51,14 +57,17 @@ def test_truediv_py_sequence() -> None:
51
57
"""Test pd.Series[float] / Python native sequence"""
52
58
b , i , f , c = [True , False , True ], [2 , 3 , 5 ], [1.0 , 2.0 , 3.0 ], [1j , 1j , 4j ]
53
59
60
+ check (assert_type (left / b , "pd.Series[float]" ), pd .Series , np .floating )
54
61
check (assert_type (left / i , "pd.Series[float]" ), pd .Series , np .floating )
55
62
check (assert_type (left / f , "pd.Series[float]" ), pd .Series , np .floating )
56
63
check (assert_type (left / c , "pd.Series[complex]" ), pd .Series , np .complexfloating )
57
64
65
+ check (assert_type (b / left , "pd.Series[float]" ), pd .Series , np .floating )
58
66
check (assert_type (i / left , "pd.Series[float]" ), pd .Series , np .floating )
59
67
check (assert_type (f / left , "pd.Series[float]" ), pd .Series , np .floating )
60
68
check (assert_type (c / left , "pd.Series[complex]" ), pd .Series , np .complexfloating )
61
69
70
+ check (assert_type (left .truediv (b ), "pd.Series[float]" ), pd .Series , np .floating )
62
71
check (assert_type (left .truediv (i ), "pd.Series[float]" ), pd .Series , np .floating )
63
72
check (assert_type (left .truediv (f ), "pd.Series[float]" ), pd .Series , np .floating )
64
73
check (
@@ -67,10 +76,12 @@ def test_truediv_py_sequence() -> None:
67
76
np .complexfloating ,
68
77
)
69
78
79
+ check (assert_type (left .div (b ), "pd.Series[float]" ), pd .Series , np .floating )
70
80
check (assert_type (left .div (i ), "pd.Series[float]" ), pd .Series , np .floating )
71
81
check (assert_type (left .div (f ), "pd.Series[float]" ), pd .Series , np .floating )
72
82
check (assert_type (left .div (c ), "pd.Series[complex]" ), pd .Series , np .complexfloating )
73
83
84
+ check (assert_type (left .rtruediv (b ), "pd.Series[float]" ), pd .Series , np .floating )
74
85
check (assert_type (left .rtruediv (i ), "pd.Series[float]" ), pd .Series , np .floating )
75
86
check (assert_type (left .rtruediv (f ), "pd.Series[float]" ), pd .Series , np .floating )
76
87
check (
@@ -79,6 +90,7 @@ def test_truediv_py_sequence() -> None:
79
90
np .complexfloating ,
80
91
)
81
92
93
+ check (assert_type (left .rdiv (b ), "pd.Series[float]" ), pd .Series , np .floating )
82
94
check (assert_type (left .rdiv (i ), "pd.Series[float]" ), pd .Series , np .floating )
83
95
check (assert_type (left .rdiv (f ), "pd.Series[float]" ), pd .Series , np .floating )
84
96
check (
@@ -93,13 +105,15 @@ def test_truediv_numpy_array() -> None:
93
105
f = np .array ([1.0 , 2.0 , 3.0 ], np .float64 )
94
106
c = np .array ([1.1j , 2.2j , 4.1j ], np .complex128 )
95
107
108
+ check (assert_type (left / b , "pd.Series[float]" ), pd .Series , np .floating )
96
109
check (assert_type (left / i , "pd.Series[float]" ), pd .Series , np .floating )
97
110
check (assert_type (left / f , "pd.Series[float]" ), pd .Series , np .floating )
98
111
check (assert_type (left / c , "pd.Series[complex]" ), pd .Series , np .complexfloating )
99
112
100
113
# `numpy` typing gives the corresponding `ndarray`s in the static type
101
114
# checking, where our `__rtruediv__` cannot override. At runtime, they return
102
115
# `Series`s with the correct element type.
116
+ check (assert_type (b / left , "npt.NDArray[np.float64]" ), pd .Series , np .floating )
103
117
check (assert_type (i / left , "npt.NDArray[np.float64]" ), pd .Series , np .floating )
104
118
check (assert_type (f / left , "npt.NDArray[np.float64]" ), pd .Series , np .floating )
105
119
check (
@@ -108,6 +122,7 @@ def test_truediv_numpy_array() -> None:
108
122
np .complexfloating ,
109
123
)
110
124
125
+ check (assert_type (left .truediv (b ), "pd.Series[float]" ), pd .Series , np .floating )
111
126
check (assert_type (left .truediv (i ), "pd.Series[float]" ), pd .Series , np .floating )
112
127
check (assert_type (left .truediv (f ), "pd.Series[float]" ), pd .Series , np .floating )
113
128
check (
@@ -116,10 +131,12 @@ def test_truediv_numpy_array() -> None:
116
131
np .complexfloating ,
117
132
)
118
133
134
+ check (assert_type (left .div (b ), "pd.Series[float]" ), pd .Series , np .floating )
119
135
check (assert_type (left .div (i ), "pd.Series[float]" ), pd .Series , np .floating )
120
136
check (assert_type (left .div (f ), "pd.Series[float]" ), pd .Series , np .floating )
121
137
check (assert_type (left .div (c ), "pd.Series[complex]" ), pd .Series , np .complexfloating )
122
138
139
+ check (assert_type (left .rtruediv (b ), "pd.Series[float]" ), pd .Series , np .floating )
123
140
check (assert_type (left .rtruediv (i ), "pd.Series[float]" ), pd .Series , np .floating )
124
141
check (assert_type (left .rtruediv (f ), "pd.Series[float]" ), pd .Series , np .floating )
125
142
check (
@@ -128,6 +145,7 @@ def test_truediv_numpy_array() -> None:
128
145
np .complexfloating ,
129
146
)
130
147
148
+ check (assert_type (left .rdiv (b ), "pd.Series[float]" ), pd .Series , np .floating )
131
149
check (assert_type (left .rdiv (i ), "pd.Series[float]" ), pd .Series , np .floating )
132
150
check (assert_type (left .rdiv (f ), "pd.Series[float]" ), pd .Series , np .floating )
133
151
check (
@@ -142,14 +160,17 @@ def test_truediv_pd_series() -> None:
142
160
f = pd .Series ([1.0 , 2.0 , 3.0 ])
143
161
c = pd .Series ([1.1j , 2.2j , 4.1j ])
144
162
163
+ check (assert_type (left / b , "pd.Series[float]" ), pd .Series , np .floating )
145
164
check (assert_type (left / i , "pd.Series[float]" ), pd .Series , np .floating )
146
165
check (assert_type (left / f , "pd.Series[float]" ), pd .Series , np .floating )
147
166
check (assert_type (left / c , "pd.Series[complex]" ), pd .Series , np .complexfloating )
148
167
168
+ check (assert_type (b / left , "pd.Series[float]" ), pd .Series , np .floating )
149
169
check (assert_type (i / left , "pd.Series[float]" ), pd .Series , np .floating )
150
170
check (assert_type (f / left , "pd.Series[float]" ), pd .Series , np .floating )
151
171
check (assert_type (c / left , "pd.Series[complex]" ), pd .Series , np .complexfloating )
152
172
173
+ check (assert_type (left .truediv (b ), "pd.Series[float]" ), pd .Series , np .floating )
153
174
check (assert_type (left .truediv (i ), "pd.Series[float]" ), pd .Series , np .floating )
154
175
check (assert_type (left .truediv (f ), "pd.Series[float]" ), pd .Series , np .floating )
155
176
check (
@@ -158,10 +179,12 @@ def test_truediv_pd_series() -> None:
158
179
np .complexfloating ,
159
180
)
160
181
182
+ check (assert_type (left .div (b ), "pd.Series[float]" ), pd .Series , np .floating )
161
183
check (assert_type (left .div (i ), "pd.Series[float]" ), pd .Series , np .floating )
162
184
check (assert_type (left .div (f ), "pd.Series[float]" ), pd .Series , np .floating )
163
185
check (assert_type (left .div (c ), "pd.Series[complex]" ), pd .Series , np .complexfloating )
164
186
187
+ check (assert_type (left .rtruediv (b ), "pd.Series[float]" ), pd .Series , np .floating )
165
188
check (assert_type (left .rtruediv (i ), "pd.Series[float]" ), pd .Series , np .floating )
166
189
check (assert_type (left .rtruediv (f ), "pd.Series[float]" ), pd .Series , np .floating )
167
190
check (
@@ -170,6 +193,7 @@ def test_truediv_pd_series() -> None:
170
193
np .complexfloating ,
171
194
)
172
195
196
+ check (assert_type (left .rdiv (b ), "pd.Series[float]" ), pd .Series , np .floating )
173
197
check (assert_type (left .rdiv (i ), "pd.Series[float]" ), pd .Series , np .floating )
174
198
check (assert_type (left .rdiv (f ), "pd.Series[float]" ), pd .Series , np .floating )
175
199
check (
0 commit comments