From 52e579b055b50caa9944ba7593d7af5031242318 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 27 Dec 2022 15:05:43 -0800 Subject: [PATCH 1/4] CI: Fix npdev error on deprecation & future warnings --- .github/workflows/ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index fe4d92507f717..d8bd327ba9799 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -76,7 +76,7 @@ jobs: - name: "Numpy Dev" env_file: actions-310-numpydev.yaml pattern: "not slow and not network and not single_cpu" - test_args: "-W error::DeprecationWarning:numpy -W error::FutureWarning:numpy" + test_args: "-W error::DeprecationWarning -W error::FutureWarning" exclude: - env_file: actions-39.yaml pyarrow_version: "6" From 23b344f69f9ab1667168d3b39b843653450d14a6 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 28 Dec 2022 17:00:56 -0800 Subject: [PATCH 2/4] Fix test: --- pandas/tests/groupby/test_categorical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/groupby/test_categorical.py b/pandas/tests/groupby/test_categorical.py index d9181830925f7..9bd69c937002a 100644 --- a/pandas/tests/groupby/test_categorical.py +++ b/pandas/tests/groupby/test_categorical.py @@ -295,7 +295,7 @@ def test_apply(ordered): idx = MultiIndex.from_arrays([missing, dense], names=["missing", "dense"]) expected = DataFrame([0, 1, 2.0], index=idx, columns=["values"]) - result = grouped.apply(lambda x: np.mean(x)) + result = grouped.apply(lambda x: np.mean(x, axis=0)) tm.assert_frame_equal(result, expected) result = grouped.mean() From 4f40244379997579610d665f84b7680ebc5ccee4 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Fri, 13 Jan 2023 11:51:04 -0800 Subject: [PATCH 3/4] Adddress np deprecationwarnings --- pandas/core/dtypes/cast.py | 10 +++++++++- pandas/tests/arithmetic/test_datetime64.py | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index dcc40c11ec778..97361fb88bc70 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -1590,7 +1590,15 @@ def maybe_cast_to_integer_array(arr: list | np.ndarray, dtype: np.dtype) -> np.n try: if not isinstance(arr, np.ndarray): - casted = np.array(arr, dtype=dtype, copy=False) + with warnings.catch_warnings(): + # We already disallow dtype=uint w/ negative numbers + # (test_constructor_coercion_signed_to_unsigned) so safe to ignore. + warnings.filterwarnings( + "ignore", + "NumPy will stop allowing conversion of out-of-bound Python int", + DeprecationWarning, + ) + casted = np.array(arr, dtype=dtype, copy=False) else: casted = arr.astype(dtype, copy=False) except OverflowError as err: diff --git a/pandas/tests/arithmetic/test_datetime64.py b/pandas/tests/arithmetic/test_datetime64.py index 02188a6e57534..2b5eb8b261af3 100644 --- a/pandas/tests/arithmetic/test_datetime64.py +++ b/pandas/tests/arithmetic/test_datetime64.py @@ -1100,7 +1100,9 @@ def test_dt64arr_addsub_intlike( dti = date_range("2016-01-01", periods=2, freq=freq, tz=tz) obj = box_with_array(dti) - other = np.array([4, -1], dtype=dtype) + other = np.array([4, -1]) + if dtype is not None: + other = other.astype(dtype) msg = "|".join( [ From 904c21ef7030eee22e77aaeb19f8ab24bb9b9738 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Fri, 13 Jan 2023 15:41:50 -0800 Subject: [PATCH 4/4] Remove supressed deprecation warnning --- pandas/tests/series/test_constructors.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index 05e40e20f1226..72b5bb7877271 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -14,10 +14,6 @@ iNaT, lib, ) -from pandas.compat import ( - IS64, - is_numpy_dev, -) from pandas.errors import IntCastingNaNError import pandas.util._test_decorators as td @@ -764,14 +760,11 @@ def test_constructor_cast(self): def test_constructor_signed_int_overflow_raises(self): # GH#41734 disallow silent overflow, enforced in 2.0 msg = "Values are too large to be losslessly converted" - numpy_warning = DeprecationWarning if is_numpy_dev or not IS64 else None with pytest.raises(ValueError, match=msg): - with tm.assert_produces_warning(numpy_warning, check_stacklevel=False): - Series([1, 200, 923442], dtype="int8") + Series([1, 200, 923442], dtype="int8") with pytest.raises(ValueError, match=msg): - with tm.assert_produces_warning(numpy_warning, check_stacklevel=False): - Series([1, 200, 923442], dtype="uint8") + Series([1, 200, 923442], dtype="uint8") @pytest.mark.parametrize( "values",