Skip to content

COMPAT: numpy test warnings #30345

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 13 commits into from
Jan 21, 2020
Merged
2 changes: 1 addition & 1 deletion pandas/plotting/_matplotlib/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def f(t):
# appropriately. Take a copy of amplitudes as otherwise numpy
# deletes the element from amplitudes itself.
coeffs = np.delete(np.copy(amplitudes), 0)
coeffs.resize(int((coeffs.size + 1) / 2), 2)
coeffs.resize(int((coeffs.size + 1) / 2), 2, refcheck=False)

# Generate the harmonics and arguments for the sin and cos
# functions.
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/arrays/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,8 @@ def test_astype_nansafe():


@pytest.mark.parametrize("ufunc", [np.abs, np.sign])
# np.sign emits a warning with nans, <https://github.com/numpy/numpy/issues/15127>
@pytest.mark.filterwarnings("ignore:invalid value encountered in sign")
def test_ufuncs_single_int(ufunc):
a = integer_array([1, 2, -3, np.nan])
result = ufunc(a)
Expand Down
18 changes: 12 additions & 6 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,25 +1210,31 @@ def test_truediv(self):
ex = "s / 1"
d = {"s": s} # noqa

res = self.eval(ex, truediv=False)
with tm.assert_produces_warning(FutureWarning):
res = self.eval(ex, truediv=False)
tm.assert_numpy_array_equal(res, np.array([1.0]))

res = self.eval(ex, truediv=True)
with tm.assert_produces_warning(FutureWarning):
res = self.eval(ex, truediv=True)
tm.assert_numpy_array_equal(res, np.array([1.0]))

res = self.eval("1 / 2", truediv=True)
with tm.assert_produces_warning(FutureWarning):
res = self.eval("1 / 2", truediv=True)
expec = 0.5
assert res == expec

res = self.eval("1 / 2", truediv=False)
with tm.assert_produces_warning(FutureWarning):
res = self.eval("1 / 2", truediv=False)
expec = 0.5
assert res == expec

res = self.eval("s / 2", truediv=False)
with tm.assert_produces_warning(FutureWarning):
res = self.eval("s / 2", truediv=False)
expec = 0.5
assert res == expec

res = self.eval("s / 2", truediv=True)
with tm.assert_produces_warning(FutureWarning):
res = self.eval("s / 2", truediv=True)
expec = 0.5
assert res == expec

Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def teardown_method(self, method):
tm.close()

@pytest.mark.slow
@pytest.mark.filterwarnings(
"ignore:Converting to PeriodArray/Index representation "
"will drop timezone information."
)
def test_ts_plot_with_tz(self, tz_aware_fixture):
# GH2877, GH17173
tz = tz_aware_fixture
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/plotting/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ def test_subplots_timeseries_y_axis(self):
ax_datetime_no_tz.get_lines()[0].get_data()[1]
== testdata["datetime_no_tz"].values
).all()
ax_datetime_all_tz = testdata.plot(y="datetime_all_tz")
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
ax_datetime_all_tz = testdata.plot(y="datetime_all_tz")
assert (
ax_datetime_all_tz.get_lines()[0].get_data()[1]
== testdata["datetime_all_tz"].values
Expand Down