Skip to content

Commit 5fad2e4

Browse files
authored
CI: fix with new numpy nightly (#50129)
* numpy compat * use is_numpy_dev * dont skip test Co-authored-by: MarcoGorelli <>
1 parent eedcb5f commit 5fad2e4

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

pandas/tests/dtypes/test_missing.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from pandas._libs import missing as libmissing
1111
from pandas._libs.tslibs import iNaT
12+
from pandas.compat import is_numpy_dev
1213

1314
from pandas.core.dtypes.common import (
1415
is_float,
@@ -460,7 +461,7 @@ def test_array_equivalent_series(val):
460461
cm = (
461462
# stacklevel is chosen to make sense when called from .equals
462463
tm.assert_produces_warning(FutureWarning, match=msg, check_stacklevel=False)
463-
if isinstance(val, str)
464+
if isinstance(val, str) and not is_numpy_dev
464465
else nullcontext()
465466
)
466467
with cm:

pandas/tests/frame/methods/test_compare.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
import pytest
33

4+
from pandas.compat import is_numpy_dev
5+
46
import pandas as pd
57
import pandas._testing as tm
68

@@ -257,8 +259,13 @@ def test_compare_ea_and_np_dtype(val1, val2):
257259
("b", "other"): np.nan,
258260
}
259261
)
260-
result = df1.compare(df2, keep_shape=True)
261-
tm.assert_frame_equal(result, expected)
262+
if val1 is pd.NA and is_numpy_dev:
263+
# can't compare with numpy array if it contains pd.NA
264+
with pytest.raises(TypeError, match="boolean value of NA is ambiguous"):
265+
result = df1.compare(df2, keep_shape=True)
266+
else:
267+
result = df1.compare(df2, keep_shape=True)
268+
tm.assert_frame_equal(result, expected)
262269

263270

264271
@pytest.mark.parametrize(

pandas/tests/indexes/object/test_indexing.py

+7
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ def test_get_indexer_non_unique_np_nats(self, np_nat_fixture, np_nat_fixture2):
114114
tm.assert_numpy_array_equal(missing, expected_missing)
115115
# dt64nat vs td64nat
116116
else:
117+
try:
118+
np_nat_fixture == np_nat_fixture2
119+
except (TypeError, OverflowError):
120+
# Numpy will raise on uncomparable types, like
121+
# np.datetime64('NaT', 'Y') and np.datetime64('NaT', 'ps')
122+
# https://github.com/numpy/numpy/issues/22762
123+
return
117124
index = Index(
118125
np.array(
119126
[

pandas/tests/series/methods/test_equals.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
from pandas._libs.missing import is_matching_na
8+
from pandas.compat import is_numpy_dev
89

910
from pandas.core.dtypes.common import is_float
1011

@@ -50,7 +51,7 @@ def test_equals_list_array(val):
5051

5152
cm = (
5253
tm.assert_produces_warning(FutureWarning, check_stacklevel=False)
53-
if isinstance(val, str)
54+
if isinstance(val, str) and not is_numpy_dev
5455
else nullcontext()
5556
)
5657
with cm:

0 commit comments

Comments
 (0)