diff --git a/pandas/compat/numpy/__init__.py b/pandas/compat/numpy/__init__.py index d747f20b8499f..0d86a63f6dbda 100644 --- a/pandas/compat/numpy/__init__.py +++ b/pandas/compat/numpy/__init__.py @@ -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" diff --git a/pandas/tests/apply/test_frame_apply_relabeling.py b/pandas/tests/apply/test_frame_apply_relabeling.py index ed3836de47051..41f8ec2576fd4 100644 --- a/pandas/tests/apply/test_frame_apply_relabeling.py +++ b/pandas/tests/apply/test_frame_apply_relabeling.py @@ -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 @@ -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]}) diff --git a/pandas/tests/dtypes/test_missing.py b/pandas/tests/dtypes/test_missing.py index db6c51d0f6991..c86407c7d6a79 100644 --- a/pandas/tests/dtypes/test_missing.py +++ b/pandas/tests/dtypes/test_missing.py @@ -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, @@ -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: diff --git a/pandas/tests/frame/methods/test_compare.py b/pandas/tests/frame/methods/test_compare.py index fe74ec8077bc9..9f9fc4a7bd8cc 100644 --- a/pandas/tests/frame/methods/test_compare.py +++ b/pandas/tests/frame/methods/test_compare.py @@ -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 @@ -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) diff --git a/pandas/tests/frame/test_unary.py b/pandas/tests/frame/test_unary.py index a9ec726ab443e..e325599684e5b 100644 --- a/pandas/tests/frame/test_unary.py +++ b/pandas/tests/frame/test_unary.py @@ -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 @@ -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\'$" ): diff --git a/pandas/tests/series/methods/test_describe.py b/pandas/tests/series/methods/test_describe.py index 0062d45cc68a0..7f706fc54897e 100644 --- a/pandas/tests/series/methods/test_describe.py +++ b/pandas/tests/series/methods/test_describe.py @@ -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, @@ -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$" ): diff --git a/pandas/tests/series/methods/test_equals.py b/pandas/tests/series/methods/test_equals.py index 9278d1b51e1aa..b94723b7cbddf 100644 --- a/pandas/tests/series/methods/test_equals.py +++ b/pandas/tests/series/methods/test_equals.py @@ -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 @@ -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: