|
8 | 8 |
|
9 | 9 | from pandas._typing import DtypeObj
|
10 | 10 |
|
11 |
| -from tests import check |
| 11 | +from tests import ( |
| 12 | + check, |
| 13 | + pytest_warns_bounded, |
| 14 | +) |
12 | 15 |
|
13 | 16 | nparr = np.array([1, 2, 3])
|
14 | 17 | arr = pd.Series([1, 2, 3])
|
@@ -52,12 +55,15 @@ def test_is_bool_dtype() -> None:
|
52 | 55 |
|
53 | 56 |
|
54 | 57 | def test_is_categorical_dtype() -> None:
|
55 |
| - check(assert_type(api.is_categorical_dtype(arr), bool), bool) |
56 |
| - check(assert_type(api.is_categorical_dtype(nparr), bool), bool) |
57 |
| - check(assert_type(api.is_categorical_dtype(dtylike), bool), bool) |
58 |
| - check(assert_type(api.is_categorical_dtype(dframe), bool), bool) |
59 |
| - check(assert_type(api.is_categorical_dtype(ind), bool), bool) |
60 |
| - check(assert_type(api.is_categorical_dtype(ExtensionDtype), bool), bool) |
| 58 | + with pytest_warns_bounded( |
| 59 | + FutureWarning, "is_categorical_dtype is deprecated", lower="2.0.99" |
| 60 | + ): |
| 61 | + check(assert_type(api.is_categorical_dtype(arr), bool), bool) |
| 62 | + check(assert_type(api.is_categorical_dtype(nparr), bool), bool) |
| 63 | + check(assert_type(api.is_categorical_dtype(dtylike), bool), bool) |
| 64 | + check(assert_type(api.is_categorical_dtype(dframe), bool), bool) |
| 65 | + check(assert_type(api.is_categorical_dtype(ind), bool), bool) |
| 66 | + check(assert_type(api.is_categorical_dtype(ExtensionDtype), bool), bool) |
61 | 67 |
|
62 | 68 |
|
63 | 69 | def test_is_complex() -> None:
|
@@ -121,12 +127,15 @@ def test_is_datetime64_ns_dtype() -> None:
|
121 | 127 |
|
122 | 128 |
|
123 | 129 | def test_is_datetime64tz_dtype() -> None:
|
124 |
| - check(assert_type(api.is_datetime64tz_dtype(arr), bool), bool) |
125 |
| - check(assert_type(api.is_datetime64tz_dtype(nparr), bool), bool) |
126 |
| - check(assert_type(api.is_datetime64tz_dtype(dtylike), bool), bool) |
127 |
| - check(assert_type(api.is_datetime64tz_dtype(dframe), bool), bool) |
128 |
| - check(assert_type(api.is_datetime64tz_dtype(ind), bool), bool) |
129 |
| - check(assert_type(api.is_datetime64tz_dtype(ExtensionDtype), bool), bool) |
| 130 | + with pytest_warns_bounded( |
| 131 | + FutureWarning, "is_datetime64tz_dtype is deprecated", lower="2.0.99" |
| 132 | + ): |
| 133 | + check(assert_type(api.is_datetime64tz_dtype(arr), bool), bool) |
| 134 | + check(assert_type(api.is_datetime64tz_dtype(nparr), bool), bool) |
| 135 | + check(assert_type(api.is_datetime64tz_dtype(dtylike), bool), bool) |
| 136 | + check(assert_type(api.is_datetime64tz_dtype(dframe), bool), bool) |
| 137 | + check(assert_type(api.is_datetime64tz_dtype(ind), bool), bool) |
| 138 | + check(assert_type(api.is_datetime64tz_dtype(ExtensionDtype), bool), bool) |
130 | 139 |
|
131 | 140 |
|
132 | 141 | def test_is_dict_like() -> None:
|
@@ -203,12 +212,15 @@ def test_is_hashable() -> None:
|
203 | 212 |
|
204 | 213 |
|
205 | 214 | def test_is_int64_dtype() -> None:
|
206 |
| - check(assert_type(api.is_int64_dtype(arr), bool), bool) |
207 |
| - check(assert_type(api.is_int64_dtype(nparr), bool), bool) |
208 |
| - check(assert_type(api.is_int64_dtype(dtylike), bool), bool) |
209 |
| - check(assert_type(api.is_int64_dtype(dframe), bool), bool) |
210 |
| - check(assert_type(api.is_int64_dtype(ind), bool), bool) |
211 |
| - # check(assert_type(api.is_int64_dtype(ExtensionDtype), bool), bool) pandas GH 50923 |
| 215 | + with pytest_warns_bounded( |
| 216 | + FutureWarning, "is_int64_dtype is deprecated", lower="2.0.99" |
| 217 | + ): |
| 218 | + check(assert_type(api.is_int64_dtype(arr), bool), bool) |
| 219 | + check(assert_type(api.is_int64_dtype(nparr), bool), bool) |
| 220 | + check(assert_type(api.is_int64_dtype(dtylike), bool), bool) |
| 221 | + check(assert_type(api.is_int64_dtype(dframe), bool), bool) |
| 222 | + check(assert_type(api.is_int64_dtype(ind), bool), bool) |
| 223 | + # check(assert_type(api.is_int64_dtype(ExtensionDtype), bool), bool) pandas GH 50923 |
212 | 224 |
|
213 | 225 |
|
214 | 226 | def test_is_integer() -> None:
|
@@ -248,13 +260,16 @@ def test_is_interval() -> None:
|
248 | 260 |
|
249 | 261 |
|
250 | 262 | def test_is_interval_dtype() -> None:
|
251 |
| - check(assert_type(api.is_interval_dtype(obj), bool), bool) |
252 |
| - check(assert_type(api.is_interval_dtype(nparr), bool), bool) |
253 |
| - check(assert_type(api.is_interval_dtype(dtylike), bool), bool) |
254 |
| - check(assert_type(api.is_interval_dtype(arr), bool), bool) |
255 |
| - check(assert_type(api.is_interval_dtype(dframe), bool), bool) |
256 |
| - check(assert_type(api.is_interval_dtype(ind), bool), bool) |
257 |
| - check(assert_type(api.is_interval_dtype(ExtensionDtype), bool), bool) |
| 263 | + with pytest_warns_bounded( |
| 264 | + FutureWarning, "is_interval_dtype is deprecated", lower="2.0.99" |
| 265 | + ): |
| 266 | + check(assert_type(api.is_interval_dtype(obj), bool), bool) |
| 267 | + check(assert_type(api.is_interval_dtype(nparr), bool), bool) |
| 268 | + check(assert_type(api.is_interval_dtype(dtylike), bool), bool) |
| 269 | + check(assert_type(api.is_interval_dtype(arr), bool), bool) |
| 270 | + check(assert_type(api.is_interval_dtype(dframe), bool), bool) |
| 271 | + check(assert_type(api.is_interval_dtype(ind), bool), bool) |
| 272 | + check(assert_type(api.is_interval_dtype(ExtensionDtype), bool), bool) |
258 | 273 |
|
259 | 274 |
|
260 | 275 | def test_is_iterator() -> None:
|
@@ -327,12 +342,15 @@ def test_is_object_dtype() -> None:
|
327 | 342 |
|
328 | 343 |
|
329 | 344 | def test_is_period_dtype() -> None:
|
330 |
| - check(assert_type(api.is_period_dtype(arr), bool), bool) |
331 |
| - check(assert_type(api.is_period_dtype(nparr), bool), bool) |
332 |
| - check(assert_type(api.is_period_dtype(dtylike), bool), bool) |
333 |
| - check(assert_type(api.is_period_dtype(dframe), bool), bool) |
334 |
| - check(assert_type(api.is_period_dtype(ind), bool), bool) |
335 |
| - check(assert_type(api.is_period_dtype(ExtensionDtype), bool), bool) |
| 345 | + with pytest_warns_bounded( |
| 346 | + FutureWarning, "is_period_dtype is deprecated", lower="2.0.99" |
| 347 | + ): |
| 348 | + check(assert_type(api.is_period_dtype(arr), bool), bool) |
| 349 | + check(assert_type(api.is_period_dtype(nparr), bool), bool) |
| 350 | + check(assert_type(api.is_period_dtype(dtylike), bool), bool) |
| 351 | + check(assert_type(api.is_period_dtype(dframe), bool), bool) |
| 352 | + check(assert_type(api.is_period_dtype(ind), bool), bool) |
| 353 | + check(assert_type(api.is_period_dtype(ExtensionDtype), bool), bool) |
336 | 354 |
|
337 | 355 |
|
338 | 356 | def test_is_re() -> None:
|
@@ -378,9 +396,10 @@ def test_is_signed_integer_dtype() -> None:
|
378 | 396 |
|
379 | 397 |
|
380 | 398 | def test_is_sparse() -> None:
|
381 |
| - check(assert_type(api.is_sparse(arr), bool), bool) |
382 |
| - check(assert_type(api.is_sparse(nparr), bool), bool) |
383 |
| - check(assert_type(api.is_sparse(dframe), bool), bool) |
| 399 | + with pytest_warns_bounded(FutureWarning, "is_sparse is deprecated", lower="2.0.99"): |
| 400 | + check(assert_type(api.is_sparse(arr), bool), bool) |
| 401 | + check(assert_type(api.is_sparse(nparr), bool), bool) |
| 402 | + check(assert_type(api.is_sparse(dframe), bool), bool) |
384 | 403 |
|
385 | 404 |
|
386 | 405 | def test_is_string_dtype() -> None:
|
|
0 commit comments