Skip to content

CI: Adjust tests for release of numpy 1.25 #53715

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
Jun 18, 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 @@ -9,6 +9,7 @@
np_version_under1p22 = _nlv < Version("1.22")
np_version_gte1p24 = _nlv >= Version("1.24")
np_version_gte1p24p3 = _nlv >= Version("1.24.3")
np_version_gte1p25 = _nlv >= Version("1.25")
is_numpy_dev = _nlv.dev is not None
_min_numpy_ver = "1.21.6"

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/apply/test_frame_apply_relabeling.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev
from pandas.compat.numpy import np_version_gte1p25

import pandas as pd
import pandas._testing as tm
Expand Down Expand Up @@ -45,7 +45,7 @@ def test_agg_relabel_multi_columns_multi_methods():
tm.assert_frame_equal(result, expected)


@pytest.mark.xfail(is_numpy_dev, reason="name of min now equals name of np.min")
@pytest.mark.xfail(np_version_gte1p25, reason="name of min now equals name of np.min")
def test_agg_relabel_partial_functions():
# GH 26513, test on partial, functools or more complex cases
df = pd.DataFrame({"A": [1, 2, 1, 2], "B": [1, 2, 3, 4], "C": [3, 4, 5, 6]})
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/dtypes/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from pandas._libs import missing as libmissing
from pandas._libs.tslibs import iNaT
from pandas.compat import is_numpy_dev
from pandas.compat.numpy import np_version_gte1p25

from pandas.core.dtypes.common import (
is_float,
Expand Down Expand Up @@ -468,7 +468,7 @@ def test_array_equivalent_series(val):
cm = (
# stacklevel is chosen to make sense when called from .equals
tm.assert_produces_warning(FutureWarning, match=msg, check_stacklevel=False)
if isinstance(val, str) and not is_numpy_dev
if isinstance(val, str) and not np_version_gte1p25
else nullcontext()
)
with cm:
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/methods/test_compare.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev
from pandas.compat.numpy import np_version_gte1p25

import pandas as pd
import pandas._testing as tm
Expand Down Expand Up @@ -269,7 +269,7 @@ def test_compare_ea_and_np_dtype(val1, val2):
# GH#18463 TODO: is this really the desired behavior?
expected.loc[1, ("a", "self")] = np.nan

if val1 is pd.NA and is_numpy_dev:
if val1 is pd.NA and np_version_gte1p25:
# can't compare with numpy array if it contains pd.NA
with pytest.raises(TypeError, match="boolean value of NA is ambiguous"):
result = df1.compare(df2, keep_shape=True)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/test_unary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev
from pandas.compat.numpy import np_version_gte1p25

import pandas as pd
import pandas._testing as tm
Expand Down Expand Up @@ -130,7 +130,7 @@ def test_pos_object(self, df):
)
def test_pos_object_raises(self, df):
# GH#21380
if is_numpy_dev:
if np_version_gte1p25:
with pytest.raises(
TypeError, match=r"^bad operand type for unary \+: \'str\'$"
):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/methods/test_describe.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import pytest

from pandas.compat import is_numpy_dev
from pandas.compat.numpy import np_version_gte1p25

from pandas.core.dtypes.common import (
is_complex_dtype,
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_numeric_result_dtype(self, any_numeric_dtype):
dtype = "complex128" if is_complex_dtype(any_numeric_dtype) else None

ser = Series([0, 1], dtype=any_numeric_dtype)
if dtype == "complex128" and is_numpy_dev:
if dtype == "complex128" and np_version_gte1p25:
with pytest.raises(
TypeError, match=r"^a must be an array of real numbers$"
):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/methods/test_equals.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

from pandas._libs.missing import is_matching_na
from pandas.compat import is_numpy_dev
from pandas.compat.numpy import np_version_gte1p25

from pandas.core.dtypes.common import is_float

Expand Down Expand Up @@ -51,7 +51,7 @@ def test_equals_list_array(val):

cm = (
tm.assert_produces_warning(FutureWarning, check_stacklevel=False)
if isinstance(val, str) and not is_numpy_dev
if isinstance(val, str) and not np_version_gte1p25
else nullcontext()
)
with cm:
Expand Down