Skip to content

Commit 6366bf0

Browse files
authored
TST: clean deprecation warnings for xref #19980 (#20013)
xfail some mpl > 2.1.2 tests
1 parent fe61299 commit 6366bf0

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

pandas/tests/plotting/test_datetimelike.py

+27-18
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,15 @@ def test_tsplot_deprecated(self):
111111

112112
@pytest.mark.slow
113113
def test_tsplot(self):
114+
114115
from pandas.tseries.plotting import tsplot
115116

116117
_, ax = self.plt.subplots()
117118
ts = tm.makeTimeSeries()
118119

119-
f = lambda *args, **kwds: tsplot(s, self.plt.Axes.plot, *args, **kwds)
120+
def f(*args, **kwds):
121+
with tm.assert_produces_warning(FutureWarning):
122+
return tsplot(s, self.plt.Axes.plot, *args, **kwds)
120123

121124
for s in self.period_ser:
122125
_check_plot_works(f, s.index.freq, ax=ax, series=s)
@@ -188,11 +191,13 @@ def check_format_of_first_point(ax, expected_string):
188191
tm.close()
189192

190193
# tsplot
191-
_, ax = self.plt.subplots()
192194
from pandas.tseries.plotting import tsplot
193-
tsplot(annual, self.plt.Axes.plot, ax=ax)
195+
_, ax = self.plt.subplots()
196+
with tm.assert_produces_warning(FutureWarning):
197+
tsplot(annual, self.plt.Axes.plot, ax=ax)
194198
check_format_of_first_point(ax, 't = 2014 y = 1.000000')
195-
tsplot(daily, self.plt.Axes.plot, ax=ax)
199+
with tm.assert_produces_warning(FutureWarning):
200+
tsplot(daily, self.plt.Axes.plot, ax=ax)
196201
check_format_of_first_point(ax, 't = 2014-01-01 y = 1.000000')
197202

198203
@pytest.mark.slow
@@ -879,12 +884,12 @@ def test_to_weekly_resampling(self):
879884
for l in ax.get_lines():
880885
assert PeriodIndex(data=l.get_xdata()).freq == idxh.freq
881886

882-
# tsplot
883-
from pandas.tseries.plotting import tsplot
884-
885887
_, ax = self.plt.subplots()
886-
tsplot(high, self.plt.Axes.plot, ax=ax)
887-
lines = tsplot(low, self.plt.Axes.plot, ax=ax)
888+
from pandas.tseries.plotting import tsplot
889+
with tm.assert_produces_warning(FutureWarning):
890+
tsplot(high, self.plt.Axes.plot, ax=ax)
891+
with tm.assert_produces_warning(FutureWarning):
892+
lines = tsplot(low, self.plt.Axes.plot, ax=ax)
888893
for l in lines:
889894
assert PeriodIndex(data=l.get_xdata()).freq == idxh.freq
890895

@@ -910,12 +915,12 @@ def test_from_weekly_resampling(self):
910915
tm.assert_numpy_array_equal(xdata, expected_h)
911916
tm.close()
912917

913-
# tsplot
914-
from pandas.tseries.plotting import tsplot
915-
916918
_, ax = self.plt.subplots()
917-
tsplot(low, self.plt.Axes.plot, ax=ax)
918-
lines = tsplot(high, self.plt.Axes.plot, ax=ax)
919+
from pandas.tseries.plotting import tsplot
920+
with tm.assert_produces_warning(FutureWarning):
921+
tsplot(low, self.plt.Axes.plot, ax=ax)
922+
with tm.assert_produces_warning(FutureWarning):
923+
lines = tsplot(high, self.plt.Axes.plot, ax=ax)
919924
for l in lines:
920925
assert PeriodIndex(data=l.get_xdata()).freq == idxh.freq
921926
xdata = l.get_xdata(orig=False)
@@ -1351,9 +1356,11 @@ def test_plot_outofbounds_datetime(self):
13511356
values = [datetime(1677, 1, 1, 12), datetime(1677, 1, 2, 12)]
13521357
ax.plot(values)
13531358

1359+
@pytest.mark.skip(
1360+
is_platform_mac(),
1361+
"skip on mac for precision display issue on older mpl")
1362+
@pytest.mark.xfail(reason="suspect on mpl 2.2.2")
13541363
def test_format_timedelta_ticks_narrow(self):
1355-
if is_platform_mac():
1356-
pytest.skip("skip on mac for precision display issue on older mpl")
13571364

13581365
if self.mpl_ge_2_0_0:
13591366
expected_labels = [''] + [
@@ -1374,9 +1381,11 @@ def test_format_timedelta_ticks_narrow(self):
13741381
for l, l_expected in zip(labels, expected_labels):
13751382
assert l.get_text() == l_expected
13761383

1384+
@pytest.mark.skip(
1385+
is_platform_mac(),
1386+
"skip on mac for precision display issue on older mpl")
1387+
@pytest.mark.xfail(reason="suspect on mpl 2.2.2")
13771388
def test_format_timedelta_ticks_wide(self):
1378-
if is_platform_mac():
1379-
pytest.skip("skip on mac for precision display issue on older mpl")
13801389

13811390
if self.mpl_ge_2_0_0:
13821391
expected_labels = [

0 commit comments

Comments
 (0)