Skip to content

Commit b467e85

Browse files
author
MarcoGorelli
committed
numpy compat
1 parent 3ece807 commit b467e85

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

pandas/tests/dtypes/test_missing.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from decimal import Decimal
44

55
import numpy as np
6+
from pkg_resources import parse_version
67
import pytest
78

89
from pandas._config import config as cf
@@ -460,7 +461,13 @@ 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 (
465+
isinstance(val, str)
466+
and not (
467+
parse_version(np.__version__) > parse_version("1.24")
468+
and "dev" in np.__version__
469+
)
470+
)
464471
else nullcontext()
465472
)
466473
with cm:

pandas/tests/frame/methods/test_compare.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
from pkg_resources import parse_version
23
import pytest
34

45
import pandas as pd
@@ -257,8 +258,17 @@ def test_compare_ea_and_np_dtype(val1, val2):
257258
("b", "other"): np.nan,
258259
}
259260
)
260-
result = df1.compare(df2, keep_shape=True)
261-
tm.assert_frame_equal(result, expected)
261+
if (
262+
val1 is pd.NA
263+
and parse_version(np.__version__) > parse_version("1.24.0")
264+
and "dev" in np.__version__
265+
):
266+
# can't compare with numpy array if it contains pd.NA
267+
with pytest.raises(TypeError, match="boolean value of NA is ambiguous"):
268+
result = df1.compare(df2, keep_shape=True)
269+
else:
270+
result = df1.compare(df2, keep_shape=True)
271+
tm.assert_frame_equal(result, expected)
262272

263273

264274
@pytest.mark.parametrize(

pandas/tests/indexes/object/test_indexing.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from decimal import Decimal
22

33
import numpy as np
4+
from pkg_resources import parse_version
45
import pytest
56

67
from pandas._libs.missing import is_matching_na
@@ -92,6 +93,11 @@ def test_get_indexer_non_unique_nas(self, nulls_fixture):
9293
tm.assert_numpy_array_equal(indexer, expected_indexer)
9394
tm.assert_numpy_array_equal(missing, expected_missing)
9495

96+
@pytest.mark.skipif(
97+
parse_version(np.__version__) > parse_version("1.24.0")
98+
and "dev" in np.__version__,
99+
reason="GH50124",
100+
)
95101
@pytest.mark.filterwarnings("ignore:elementwise comp:DeprecationWarning")
96102
def test_get_indexer_non_unique_np_nats(self, np_nat_fixture, np_nat_fixture2):
97103
expected_missing = np.array([], dtype=np.intp)

pandas/tests/series/methods/test_equals.py

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import copy
33

44
import numpy as np
5+
from pkg_resources import parse_version
56
import pytest
67

78
from pandas._libs.missing import is_matching_na
@@ -51,6 +52,10 @@ def test_equals_list_array(val):
5152
cm = (
5253
tm.assert_produces_warning(FutureWarning, check_stacklevel=False)
5354
if isinstance(val, str)
55+
and not (
56+
parse_version(np.__version__) > parse_version("1.24.0")
57+
and "dev" in np.__version__
58+
)
5459
else nullcontext()
5560
)
5661
with cm:

0 commit comments

Comments
 (0)