Skip to content

CI: Fix npdev error on deprecation & future warnings #50452

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 12 commits into from
Jan 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
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/arithmetic/test_datetime64.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand Down
11 changes: 2 additions & 9 deletions pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down