Skip to content

Commit fe98101

Browse files
authored
CI: Fix npdev error on deprecation & future warnings (#50452)
* CI: Fix npdev error on deprecation & future warnings * Fix test: * Adddress np deprecationwarnings * Remove supressed deprecation warnning
1 parent d72e244 commit fe98101

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

.github/workflows/ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
- name: "Numpy Dev"
7878
env_file: actions-310-numpydev.yaml
7979
pattern: "not slow and not network and not single_cpu"
80-
test_args: "-W error::DeprecationWarning:numpy -W error::FutureWarning:numpy"
80+
test_args: "-W error::DeprecationWarning -W error::FutureWarning"
8181
error_on_warnings: "0"
8282
exclude:
8383
- env_file: actions-38.yaml

pandas/core/dtypes/cast.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,15 @@ def maybe_cast_to_integer_array(arr: list | np.ndarray, dtype: np.dtype) -> np.n
15901590

15911591
try:
15921592
if not isinstance(arr, np.ndarray):
1593-
casted = np.array(arr, dtype=dtype, copy=False)
1593+
with warnings.catch_warnings():
1594+
# We already disallow dtype=uint w/ negative numbers
1595+
# (test_constructor_coercion_signed_to_unsigned) so safe to ignore.
1596+
warnings.filterwarnings(
1597+
"ignore",
1598+
"NumPy will stop allowing conversion of out-of-bound Python int",
1599+
DeprecationWarning,
1600+
)
1601+
casted = np.array(arr, dtype=dtype, copy=False)
15941602
else:
15951603
casted = arr.astype(dtype, copy=False)
15961604
except OverflowError as err:

pandas/tests/arithmetic/test_datetime64.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,9 @@ def test_dt64arr_addsub_intlike(
11001100
dti = date_range("2016-01-01", periods=2, freq=freq, tz=tz)
11011101

11021102
obj = box_with_array(dti)
1103-
other = np.array([4, -1], dtype=dtype)
1103+
other = np.array([4, -1])
1104+
if dtype is not None:
1105+
other = other.astype(dtype)
11041106

11051107
msg = "|".join(
11061108
[

pandas/tests/series/test_constructors.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
iNaT,
1515
lib,
1616
)
17-
from pandas.compat import (
18-
IS64,
19-
is_numpy_dev,
20-
)
2117
from pandas.errors import IntCastingNaNError
2218
import pandas.util._test_decorators as td
2319

@@ -764,14 +760,11 @@ def test_constructor_cast(self):
764760
def test_constructor_signed_int_overflow_raises(self):
765761
# GH#41734 disallow silent overflow, enforced in 2.0
766762
msg = "Values are too large to be losslessly converted"
767-
numpy_warning = DeprecationWarning if is_numpy_dev or not IS64 else None
768763
with pytest.raises(ValueError, match=msg):
769-
with tm.assert_produces_warning(numpy_warning, check_stacklevel=False):
770-
Series([1, 200, 923442], dtype="int8")
764+
Series([1, 200, 923442], dtype="int8")
771765

772766
with pytest.raises(ValueError, match=msg):
773-
with tm.assert_produces_warning(numpy_warning, check_stacklevel=False):
774-
Series([1, 200, 923442], dtype="uint8")
767+
Series([1, 200, 923442], dtype="uint8")
775768

776769
@pytest.mark.parametrize(
777770
"values",

0 commit comments

Comments
 (0)