FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use warnings.warn, not logging.warning, in microseconds locator warning. by anntzer · Pull Request #15000 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 4 additions & 3 deletions lib/matplotlib/dates.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1457,9 +1457,10 @@ def get_locator(self, dmin, dmax):
else:
locator = MicrosecondLocator(interval, tz=self.tz)
if dmin.year > 20 and interval < 1000:
_log.warning('Plotting microsecond time intervals is not well '
'supported. Please see the MicrosecondLocator '
'documentation for details.')
cbook._warn_external(
'Plotting microsecond time intervals is not well '
'supported; please see the MicrosecondLocator '
'documentation for details.')

locator.set_axis(self.axis)

Expand Down
12 changes: 10 additions & 2 deletions lib/matplotlib/tests/test_dates.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import datetime
try:
from contextlib import nullcontext
except ImportError:
from contextlib import ExitStack as nullcontext # Py 3.6.

import dateutil.tz
import dateutil.rrule
Expand Down Expand Up @@ -369,7 +373,9 @@ def _create_auto_date_locator(date1, date2):
for t_delta, expected in results:
d2 = d1 + t_delta
locator = _create_auto_date_locator(d1, d2)
assert list(map(str, mdates.num2date(locator()))) == expected
with (pytest.warns(UserWarning) if t_delta.microseconds
else nullcontext()):
assert list(map(str, mdates.num2date(locator()))) == expected


def test_auto_date_locator_intmult():
Expand Down Expand Up @@ -444,7 +450,9 @@ def _create_auto_date_locator(date1, date2):
for t_delta, expected in results:
d2 = d1 + t_delta
locator = _create_auto_date_locator(d1, d2)
assert list(map(str, mdates.num2date(locator()))) == expected
with (pytest.warns(UserWarning) if t_delta.microseconds
else nullcontext()):
assert list(map(str, mdates.num2date(locator()))) == expected


def test_concise_formatter():
Expand Down

Back | FazBrowse Home | New Git URL