diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index f7bd5980439e3..d3ad2710a0efa 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -77,7 +77,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" error_on_warnings: "0" exclude: - env_file: actions-38.yaml 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( [ 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",