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
20 changes: 14 additions & 6 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,25 +1210,33 @@ def test_truediv(self):
ex = "s / 1"
d = {"s": s} # noqa

res = self.eval(ex, truediv=False)
# FutureWarning: The `truediv` parameter in pd.eval is deprecated and will be
# removed in a future version.
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
14 changes: 12 additions & 2 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
""" Test cases for time series specific (freq conversion, etc) """
from datetime import date, datetime, time, timedelta
from datetime import date, datetime, time, timedelta, timezone
import pickle
import sys

import dateutil
import numpy as np
import pytest
import pytz

import pandas.util._test_decorators as td

Expand Down Expand Up @@ -49,7 +51,15 @@ def test_ts_plot_with_tz(self, tz_aware_fixture):
tz = tz_aware_fixture
index = date_range("1/1/2011", periods=2, freq="H", tz=tz)
ts = Series([188.5, 328.25], index=index)
_check_plot_works(ts.plot)
if tz in ["UTC", pytz.UTC, timezone.utc] or isinstance(
tz, dateutil.tz.tz.tzutc
):
# Converting to PeriodArray/Index representation will drop timezone
# information.
with tm.assert_produces_warning(UserWarning):
_check_plot_works(ts.plot)
else:
_check_plot_works(ts.plot)

def test_fontsize_set_correctly(self):
# For issue #8765
Expand Down
7 changes: 6 additions & 1 deletion pandas/tests/plotting/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,12 @@ 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")
# FutureWarning: Converting timezone-aware DatetimeArray to timezone-naive
# ndarray with 'datetime64[ns]' dtype. In the future, this will return an
# ndarray with 'object' dtype where each element is a 'pandas.Timestamp' with
# the correct '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