|
2 | 2 |
|
3 | 3 | import datetime |
4 | 4 | import datetime as dt |
5 | | -import sys |
6 | 5 | from typing import ( |
7 | 6 | TYPE_CHECKING, |
8 | 7 | Any, |
|
52 | 51 | PeriodSeries: TypeAlias = pd.Series |
53 | 52 | OffsetSeries: TypeAlias = pd.Series |
54 | 53 |
|
55 | | -MYPY = False |
56 | | - |
57 | 54 |
|
58 | 55 | def test_interval() -> None: |
59 | 56 | interval_i = pd.Interval(0, 1, closed="left") |
@@ -1375,55 +1372,52 @@ def test_timestamp_cmp() -> None: |
1375 | 1372 | ne = check(assert_type(ts != c_dt_datetime, bool), bool) |
1376 | 1373 | assert eq != ne |
1377 | 1374 |
|
1378 | | - eq_arr = check( |
| 1375 | + eq_arr1 = check( |
1379 | 1376 | assert_type(ts == c_datetimeindex, np_1darray[np.bool]), np_1darray[np.bool] |
1380 | 1377 | ) |
1381 | | - ne_arr = check( |
| 1378 | + ne_arr1 = check( |
1382 | 1379 | assert_type(ts != c_datetimeindex, np_1darray[np.bool]), np_1darray[np.bool] |
1383 | 1380 | ) |
1384 | | - assert (eq_arr != ne_arr).all() |
1385 | | - eq_arr = check( |
| 1381 | + assert (eq_arr1 != ne_arr1).all() |
| 1382 | + eq_arr2 = check( |
1386 | 1383 | assert_type(ts == c_unknown_index, np_1darray[np.bool]), np_1darray[np.bool] |
1387 | 1384 | ) |
1388 | | - ne_arr = check( |
| 1385 | + ne_arr2 = check( |
1389 | 1386 | assert_type(ts != c_unknown_index, np_1darray[np.bool]), np_1darray[np.bool] |
1390 | 1387 | ) |
1391 | | - assert (eq_arr != ne_arr).all() |
| 1388 | + assert (eq_arr2 != ne_arr2).all() |
1392 | 1389 |
|
1393 | | - if sys.version_info >= (3, 11) or not MYPY: |
1394 | | - # tests in this block fail with mypy on Python 3.10 in CI only |
1395 | | - # I couldn't reproduce the failure locally so skip mypy on Python 3.10 |
1396 | | - eq_arr = check( |
1397 | | - assert_type(ts == c_np_ndarray_dt64, np_ndarray_bool), np.ndarray, np.bool_ |
1398 | | - ) |
1399 | | - ne_arr = check( |
1400 | | - assert_type(ts != c_np_ndarray_dt64, np_ndarray_bool), np.ndarray, np.bool_ |
1401 | | - ) |
1402 | | - assert (eq_arr != ne_arr).all() |
1403 | | - # TODO: the following should be 2D-arrays but it doesn't work in mypy |
1404 | | - eq_arr = check( |
1405 | | - assert_type(ts == c_np_2darray_dt64, np_ndarray_bool), np_ndarray_bool |
1406 | | - ) |
1407 | | - ne_arr = check( |
1408 | | - assert_type(ts != c_np_2darray_dt64, np_ndarray_bool), np_ndarray_bool |
1409 | | - ) |
1410 | | - assert (eq_arr != ne_arr).all() |
| 1390 | + eq_arr3 = check( |
| 1391 | + assert_type(ts == c_np_ndarray_dt64, np_ndarray_bool), np.ndarray, np.bool_ |
| 1392 | + ) |
| 1393 | + ne_arr3 = check( |
| 1394 | + assert_type(ts != c_np_ndarray_dt64, np_ndarray_bool), np.ndarray, np.bool_ |
| 1395 | + ) |
| 1396 | + assert (eq_arr3 != ne_arr3).all() |
1411 | 1397 |
|
1412 | | - eq_s = check( |
| 1398 | + eq_arr4 = check( |
| 1399 | + assert_type(ts == c_np_2darray_dt64, np_2darray[np.bool]), np_2darray[np.bool] |
| 1400 | + ) |
| 1401 | + ne_arr4 = check( |
| 1402 | + assert_type(ts != c_np_2darray_dt64, np_2darray[np.bool]), np_2darray[np.bool] |
| 1403 | + ) |
| 1404 | + assert (eq_arr4 != ne_arr4).all() |
| 1405 | + |
| 1406 | + eq_s1 = check( |
1413 | 1407 | assert_type(ts == c_series_timestamp, "pd.Series[bool]"), pd.Series, np.bool_ |
1414 | 1408 | ) |
1415 | | - ne_s = check( |
| 1409 | + ne_s1 = check( |
1416 | 1410 | assert_type(ts != c_series_timestamp, "pd.Series[bool]"), pd.Series, np.bool_ |
1417 | 1411 | ) |
1418 | | - assert (eq_s != ne_s).all() |
| 1412 | + assert (eq_s1 != ne_s1).all() |
1419 | 1413 |
|
1420 | | - eq_s = check( |
| 1414 | + eq_s2 = check( |
1421 | 1415 | assert_type(ts == c_series_dt64, "pd.Series[bool]"), pd.Series, np.bool_ |
1422 | 1416 | ) |
1423 | | - ne_s = check( |
| 1417 | + ne_s2 = check( |
1424 | 1418 | assert_type(ts != c_series_dt64, "pd.Series[bool]"), pd.Series, np.bool_ |
1425 | 1419 | ) |
1426 | | - assert (eq_s != ne_s).all() |
| 1420 | + assert (eq_s2 != ne_s2).all() |
1427 | 1421 |
|
1428 | 1422 |
|
1429 | 1423 | def test_timestamp_eq_ne_rhs() -> None: |
|
0 commit comments