Skip to content

Commit

Permalink
Backport PR #53715: CI: Adjust tests for release of numpy 1.25 (#53716)
Browse files Browse the repository at this point in the history
  • Loading branch information
lithomas1 committed Jun 19, 2023
1 parent 9667eb5 commit fbb97d0
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions pandas/compat/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
np_version_gte1p22 = _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.20.3"

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 @@ -460,7 +460,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 @@ -265,7 +265,7 @@ def test_compare_ea_and_np_dtype(val1, val2):
("b", "other"): 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

0 comments on commit fbb97d0

Please sign in to comment.