Skip to content

Commit efc4f70

Browse files
jbrockmendelukarroum
authored andcommitted
TST: avoid/suppress DeprecationWarnings (pandas-dev#37570)
1 parent ac2cdf5 commit efc4f70

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

pandas/core/arrays/boolean.py

+5
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,11 @@ def _arith_method(self, other, op):
664664
dtype = "bool"
665665
result = np.zeros(len(self._data), dtype=dtype)
666666
else:
667+
if op_name in {"pow", "rpow"} and isinstance(other, np.bool_):
668+
# Avoid DeprecationWarning: In future, it will be an error
669+
# for 'np.bool_' scalars to be interpreted as an index
670+
other = bool(other)
671+
667672
with np.errstate(all="ignore"):
668673
result = op(self._data, other)
669674

pandas/tests/indexes/test_index_new.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,25 @@ def test_constructor_infer_nat_dt_like(
9090
data = [ctor]
9191
data.insert(pos, nulls_fixture)
9292

93+
warn = None
9394
if nulls_fixture is NA:
9495
expected = Index([NA, NaT])
9596
mark = pytest.mark.xfail(reason="Broken with np.NaT ctor; see GH 31884")
9697
request.node.add_marker(mark)
98+
# GH#35942 numpy will emit a DeprecationWarning within the
99+
# assert_index_equal calls. Since we can't do anything
100+
# about it until GH#31884 is fixed, we suppress that warning.
101+
warn = DeprecationWarning
97102

98103
result = Index(data)
99-
tm.assert_index_equal(result, expected)
104+
105+
with tm.assert_produces_warning(warn):
106+
tm.assert_index_equal(result, expected)
100107

101108
result = Index(np.array(data, dtype=object))
102-
tm.assert_index_equal(result, expected)
109+
110+
with tm.assert_produces_warning(warn):
111+
tm.assert_index_equal(result, expected)
103112

104113
@pytest.mark.parametrize("swap_objs", [True, False])
105114
def test_constructor_mixed_nat_objs_infers_object(self, swap_objs):

0 commit comments

Comments
 (0)