Skip to content

Backport PR #52867 on branch 2.0.x (Adjust unxfail condition for nat test for new numpy release) #52875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pandas/compat/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
np_version_under1p22 = _nlv < Version("1.22")
np_version_gte1p22 = _nlv >= Version("1.22")
np_version_gte1p24 = _nlv >= Version("1.24")
np_version_gte1p24p3 = _nlv >= Version("1.24.3")
is_numpy_dev = _nlv.dev is not None
_min_numpy_ver = "1.20.3"

Expand Down
27 changes: 16 additions & 11 deletions pandas/tests/scalar/test_nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytz

from pandas._libs.tslibs import iNaT
from pandas.compat import is_numpy_dev
from pandas.compat.numpy import np_version_gte1p24p3

from pandas.core.dtypes.common import is_datetime64_any_dtype

Expand Down Expand Up @@ -525,24 +525,29 @@ def test_to_numpy_alias():
[
Timedelta(0),
Timedelta(0).to_pytimedelta(),
Timedelta(0).to_timedelta64(),
pytest.param(
Timedelta(0).to_timedelta64(),
marks=pytest.mark.xfail(
not np_version_gte1p24p3,
reason="td64 doesn't return NotImplemented, see numpy#17017",
),
),
Timestamp(0),
Timestamp(0).to_pydatetime(),
Timestamp(0).to_datetime64(),
pytest.param(
Timestamp(0).to_datetime64(),
marks=pytest.mark.xfail(
not np_version_gte1p24p3,
reason="dt64 doesn't return NotImplemented, see numpy#17017",
),
),
Timestamp(0).tz_localize("UTC"),
NaT,
],
)
def test_nat_comparisons(compare_operators_no_eq_ne, other, request):
def test_nat_comparisons(compare_operators_no_eq_ne, other):
# GH 26039
opname = compare_operators_no_eq_ne
if isinstance(other, (np.datetime64, np.timedelta64)) and (
opname in ["__eq__", "__ne__"] or not is_numpy_dev
):
mark = pytest.mark.xfail(
reason="dt64/td64 don't return NotImplemented, see numpy#17017",
)
request.node.add_marker(mark)

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

Expand Down