Skip to content

Commit 4566159

Browse files
jbrockmendelclaude
andauthored
TST: fix Numpy Nightly CI failure in test_dti_union_mixed (pandas-dev#65848)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 7fcc6bf commit 4566159

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

pandas/compat/numpy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
np_version_gt2_2 = _nlv >= Version("2.2.0")
1414
np_version_gt2_3 = _nlv >= Version("2.3.0")
1515
np_version_gt2_5 = _nlv >= Version("2.5.0")
16+
np_version_gt2_6 = _nlv >= Version("2.6.0.dev0")
1617
is_numpy_dev = _nlv.dev is not None
1718
_min_numpy_ver = "1.26.0"
1819

pandas/tests/indexes/datetimes/test_setops.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import numpy as np
88
import pytest
99

10+
from pandas.compat.numpy import np_version_gt2_6
1011
import pandas.util._test_decorators as td
1112

1213
import pandas as pd
@@ -527,7 +528,11 @@ def test_dti_union_mixed(self):
527528
# GH#21671
528529
rng = DatetimeIndex([Timestamp("2011-01-01"), pd.NaT])
529530
rng2 = DatetimeIndex(["2012-01-01", "2012-01-02"], tz="Asia/Tokyo")
530-
result = rng.union(rng2)
531+
# numpy>=2.6 object-dtype sort compares the tz-naive and tz-aware
532+
# Timestamps directly, so safe_sort fails and union warns
533+
warn = RuntimeWarning if np_version_gt2_6 else None
534+
with tm.assert_produces_warning(warn, match="sort order is undefined"):
535+
result = rng.union(rng2)
531536
expected = Index(
532537
[
533538
Timestamp("2011-01-01"),

0 commit comments

Comments
 (0)