Skip to content

Commit 4c23901

Browse files
author
Marco Gorelli
committed
👌 use pandas testing module to check for no warnings, dont ignore warnings, remove whatsnewentry
1 parent 120ba63 commit 4c23901

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

doc/source/whatsnew/v1.1.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ I/O
198198
Plotting
199199
^^^^^^^^
200200

201-
- Plotting tz-aware timeseries no longer gives UserWarning (:issue:`31205`)
201+
-
202202
-
203203

204204
Groupby/resample/rolling

pandas/plotting/_matplotlib/timeseries.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# TODO: Use the fact that axis can have units to simplify the process
22

33
import functools
4-
import warnings
54

65
import numpy as np
76

@@ -252,9 +251,7 @@ def _maybe_convert_index(ax, data):
252251
freq = frequencies.get_period_alias(freq)
253252

254253
if isinstance(data.index, ABCDatetimeIndex):
255-
with warnings.catch_warnings():
256-
warnings.filterwarnings("ignore", category=UserWarning)
257-
data = data.to_period(freq=freq)
254+
data = data.tz_localize(None).to_period(freq=freq)
258255
elif isinstance(data.index, ABCPeriodIndex):
259256
data.index = data.index.asfreq(freq=freq)
260257
return data

pandas/tests/plotting/test_datetimelike.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ def teardown_method(self, method):
4444
tm.close()
4545

4646
@pytest.mark.slow
47-
def test_ts_plot_with_tz(self, tz_aware_fixture, recwarn):
47+
def test_ts_plot_with_tz(self, tz_aware_fixture):
4848
# GH2877, GH17173, GH31205
4949
tz = tz_aware_fixture
5050
index = date_range("1/1/2011", periods=2, freq="H", tz=tz)
5151
ts = Series([188.5, 328.25], index=index)
52-
_check_plot_works(ts.plot)
53-
assert not any(isinstance(i.message, UserWarning) for i in recwarn)
52+
with tm.assert_produces_warning(None):
53+
_check_plot_works(ts.plot)
5454

5555
def test_fontsize_set_correctly(self):
5656
# For issue #8765

0 commit comments

Comments
 (0)