8000 MNT: Deprecate date_ticker_factory (#23081) · matplotlib/matplotlib@037fcca · GitHub
[go: up one dir, main page]

Skip to content

Commit 037fcca

Browse files
oscargustimhoffm
andauthored
MNT: Deprecate date_ticker_factory (#23081)
* Deprecate date_ticker_factory * Update doc/api/next_api_changes/deprecations/23081-OG.rst Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent 846864e commit 037fcca

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
``date_ticker_factory`` deprecated
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The ``date_ticker_factory`` method in the `matplotlib.dates` module is
5+
deprecated. Instead use `~.AutoDateLocator` and `~.AutoDateFormatter` for a
6+
more flexible and scalable locator and formatter.
7+
8+
If you need the exact ``date_ticker_factory`` behavior, please copy the code.

lib/matplotlib/dates.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,8 @@ def num2epoch(d):
17821782
return np.asarray(d) * SEC_PER_DAY - dt
17831783

17841784

1785+
@_api.deprecated("3.6", alternative="`AutoDateLocator` and `AutoDateFormatter`"
1786+
" or vendor the code")
17851787
def date_ticker_factory(span, tz=None, numticks=5):
17861788
"""
17871789
Create a date locator with *numticks* (approx) and a date formatter

lib/matplotlib/tests/test_dates.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,8 +1319,9 @@ def test_concise_formatter_call():
13191319
(200, mdates.MonthLocator),
13201320
(2000, mdates.YearLocator)))
13211321
def test_date_ticker_factory(span, expected_locator):
1322-
locator, _ = mdates.date_ticker_factory(span)
1323-
assert isinstance(locator, expected_locator)
1322+
with pytest.warns(_api.MatplotlibDeprecationWarning):
1323+
locator, _ = mdates.date_ticker_factory(span)
1324+
assert isinstance(locator, expected_locator)
13241325

13251326

13261327
def test_usetex_newline():

0 commit comments

Comments
 (0)
0