Skip to content

Commit 22f9e93

Browse files
authored
Backport PR pandas-dev#52867 on branch 2.0.x (Adjust unxfail condition for nat test for new numpy release) (pandas-dev#52875)
Adjust unxfail condition for nat test for new numpy release (pandas-dev#52867) (cherry picked from commit ce94afa)
1 parent 7a0aa9f commit 22f9e93

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

pandas/compat/numpy/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
np_version_under1p22 = _nlv < Version("1.22")
1111
np_version_gte1p22 = _nlv >= Version("1.22")
1212
np_version_gte1p24 = _nlv >= Version("1.24")
13+
np_version_gte1p24p3 = _nlv >= Version("1.24.3")
1314
is_numpy_dev = _nlv.dev is not None
1415
_min_numpy_ver = "1.20.3"
1516

pandas/tests/scalar/test_nat.py

+16-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytz
1010

1111
from pandas._libs.tslibs import iNaT
12-
from pandas.compat import is_numpy_dev
12+
from pandas.compat.numpy import np_version_gte1p24p3
1313

1414
from pandas.core.dtypes.common import is_datetime64_any_dtype
1515

@@ -525,24 +525,29 @@ def test_to_numpy_alias():
525525
[
526526
Timedelta(0),
527527
Timedelta(0).to_pytimedelta(),
528-
Timedelta(0).to_timedelta64(),
528+
pytest.param(
529+
Timedelta(0).to_timedelta64(),
530+
marks=pytest.mark.xfail(
531+
not np_version_gte1p24p3,
532+
reason="td64 doesn't return NotImplemented, see numpy#17017",
533+
),
534+
),
529535
Timestamp(0),
530536
Timestamp(0).to_pydatetime(),
531-
Timestamp(0).to_datetime64(),
537+
pytest.param(
538+
Timestamp(0).to_datetime64(),
539+
marks=pytest.mark.xfail(
540+
not np_version_gte1p24p3,
541+
reason="dt64 doesn't return NotImplemented, see numpy#17017",
542+
),
543+
),
532544
Timestamp(0).tz_localize("UTC"),
533545
NaT,
534546
],
535547
)
536-
def test_nat_comparisons(compare_operators_no_eq_ne, other, request):
548+
def test_nat_comparisons(compare_operators_no_eq_ne, other):
537549
# GH 26039
538550
opname = compare_operators_no_eq_ne
539-
if isinstance(other, (np.datetime64, np.timedelta64)) and (
540-
opname in ["__eq__", "__ne__"] or not is_numpy_dev
541-
):
542-
mark = pytest.mark.xfail(
543-
reason="dt64/td64 don't return NotImplemented, see numpy#17017",
544-
)
545-
request.node.add_marker(mark)
546551

547552
assert getattr(NaT, opname)(other) is False
548553

0 commit comments

Comments
 (0)