From 711afeb97603a10443e1543e3951654c78eb0de5 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Fri, 20 May 2022 09:01:41 +0200 Subject: [PATCH 1/2] Deprecate date_ticker_factory --- doc/api/next_api_changes/deprecations/23081-OG.rst | 8 ++++++++ lib/matplotlib/dates.py | 2 ++ lib/matplotlib/tests/test_dates.py | 5 +++-- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 doc/api/next_api_changes/deprecations/23081-OG.rst diff --git a/doc/api/next_api_changes/deprecations/23081-OG.rst b/doc/api/next_api_changes/deprecations/23081-OG.rst new file mode 100644 index 000000000000..cb0100f2ba60 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/23081-OG.rst @@ -0,0 +1,8 @@ +``date_ticker_factory`` deprecated +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``date_ticker_factory`` method in the `matplotlib.dates` module is +deprecated. Instead use `~.AutoDateLocator` and `~.AutoDateFormatter` for a +more flexible and scalable locator and formatter. + +The code can also be vendored if the fixed behaviour is expected. diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index 30b2f40466f0..1eb73dbef4fe 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -1782,6 +1782,8 @@ def num2epoch(d): return np.asarray(d) * SEC_PER_DAY - dt +@_api.deprecated("3.6", alternative="`AutoDateLocator` and `AutoDateFormatter`" + " or vendor the code") def date_ticker_factory(span, tz=None, numticks=5): """ Create a date locator with *numticks* (approx) and a date formatter diff --git a/lib/matplotlib/tests/test_dates.py b/lib/matplotlib/tests/test_dates.py index 5258da36a7e7..604a40689fdf 100644 --- a/lib/matplotlib/tests/test_dates.py +++ b/lib/matplotlib/tests/test_dates.py @@ -1319,8 +1319,9 @@ def test_concise_formatter_call(): (200, mdates.MonthLocator), (2000, mdates.YearLocator))) def test_date_ticker_factory(span, expected_locator): - locator, _ = mdates.date_ticker_factory(span) - assert isinstance(locator, expected_locator) + with pytest.warns(_api.MatplotlibDeprecationWarning): + locator, _ = mdates.date_ticker_factory(span) + assert isinstance(locator, expected_locator) def test_usetex_newline(): From 56909f470062cf0944fd129d76e65a9783164a1a Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 21 May 2022 10:46:58 +0200 Subject: [PATCH 2/2] Update doc/api/next_api_changes/deprecations/23081-OG.rst Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> --- doc/api/next_api_changes/deprecations/23081-OG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/next_api_changes/deprecations/23081-OG.rst b/doc/api/next_api_changes/deprecations/23081-OG.rst index cb0100f2ba60..da7f697023c0 100644 --- a/doc/api/next_api_changes/deprecations/23081-OG.rst +++ b/doc/api/next_api_changes/deprecations/23081-OG.rst @@ -5,4 +5,4 @@ The ``date_ticker_factory`` method in the `matplotlib.dates` module is deprecated. Instead use `~.AutoDateLocator` and `~.AutoDateFormatter` for a more flexible and scalable locator and formatter. -The code can also be vendored if the fixed behaviour is expected. +If you need the exact ``date_ticker_factory`` behavior, please copy the code.