diff --git a/doc/api/next_api_changes/removals/24128-OG.rst b/doc/api/next_api_changes/removals/24128-OG.rst new file mode 100644 index 000000000000..2a17a6c54689 --- /dev/null +++ b/doc/api/next_api_changes/removals/24128-OG.rst @@ -0,0 +1,17 @@ +``epoch2num`` and ``num2epoch`` are removed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +These methods convert from unix timestamps to matplotlib floats, but are not +used internally to Matplotlib, and should not be needed by end users. To +convert a unix timestamp to datetime, simply use +`datetime.datetime.utcfromtimestamp`, or to use NumPy `~numpy.datetime64` +``dt = np.datetime64(e*1e6, 'us')``. + + +Locator and Formatter wrapper methods +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``set_view_interval``, ``set_data_interval`` and ``set_bounds`` methods of +`.Locator`\s and `.Formatter`\s (and their common base class, TickHelper) are +removed. Directly manipulate the view and data intervals on the underlying +axis instead. diff --git a/doc/api/prev_api_changes/api_changes_3.3.0/deprecations.rst b/doc/api/prev_api_changes/api_changes_3.3.0/deprecations.rst index 22aa93f89931..70babe0f7a56 100644 --- a/doc/api/prev_api_changes/api_changes_3.3.0/deprecations.rst +++ b/doc/api/prev_api_changes/api_changes_3.3.0/deprecations.rst @@ -545,8 +545,8 @@ experimental and may change in the future. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... is deprecated. -`.epoch2num` and `.num2epoch` are deprecated -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``epoch2num`` and ``num2epoch`` are deprecated +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ These are unused and can be easily reproduced by other date tools. `.get_epoch` will return Matplotlib's epoch. diff --git a/doc/api/prev_api_changes/api_changes_3.3.1.rst b/doc/api/prev_api_changes/api_changes_3.3.1.rst index b3383a4e5fd2..3eda8a9a3a1a 100644 --- a/doc/api/prev_api_changes/api_changes_3.3.1.rst +++ b/doc/api/prev_api_changes/api_changes_3.3.1.rst @@ -15,7 +15,7 @@ reverts the deprecation. Functions ``epoch2num`` and ``dates.julian2num`` use ``date.epoch`` rcParam ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Now `~.dates.epoch2num` and (undocumented) ``julian2num`` return floating point +Now ``epoch2num`` and (undocumented) ``julian2num`` return floating point days since `~.dates.get_epoch` as set by :rc:`date.epoch`, instead of floating point days since the old epoch of "0000-12-31T00:00:00". If needed, you can translate from the new to old values as diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index 672ea2c3b003..97803c4007b6 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -187,10 +187,9 @@ from matplotlib import _api, cbook, ticker, units __all__ = ('datestr2num', 'date2num', 'num2date', 'num2timedelta', 'drange', - 'epoch2num', 'num2epoch', 'set_epoch', 'get_epoch', 'DateFormatter', - 'ConciseDateFormatter', 'AutoDateFormatter', - 'DateLocator', 'RRuleLocator', 'AutoDateLocator', 'YearLocator', - 'MonthLocator', 'WeekdayLocator', + 'set_epoch', 'get_epoch', 'DateFormatter', 'ConciseDateFormatter', + 'AutoDateFormatter', 'DateLocator', 'RRuleLocator', + 'AutoDateLocator', 'YearLocator', 'MonthLocator', 'WeekdayLocator', 'DayLocator', 'HourLocator', 'MinuteLocator', 'SecondLocator', 'MicrosecondLocator', 'rrule', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU', @@ -1737,16 +1736,6 @@ def set_axis(self, axis): self._wrapped_locator.set_axis(axis) return super().set_axis(axis) - @_api.deprecated("3.5", alternative="`.Axis.set_view_interval`") - def set_view_interval(self, vmin, vmax): - self._wrapped_locator.set_view_interval(vmin, vmax) - return super().set_view_interval(vmin, vmax) - - @_api.deprecated("3.5", alternative="`.Axis.set_data_interval`") - def set_data_interval(self, vmin, vmax): - self._wrapped_locator.set_data_interval(vmin, vmax) - return super().set_data_interval(vmin, vmax) - def __call__(self): # if no data have been set, this will tank with a ValueError try: @@ -1778,52 +1767,6 @@ def _get_interval(self): return self._interval -@_api.deprecated( - "3.5", - alternative="``[date2num(datetime.utcfromtimestamp(t)) for t in e]`` or " - "numpy.datetime64 types") -def epoch2num(e): - """ - Convert UNIX time to days since Matplotlib epoch. - - Parameters - ---------- - e : list of floats - Time in seconds since 1970-01-01. - - Returns - ------- - `numpy.array` - Time in days since Matplotlib epoch (see `~.dates.get_epoch()`). - """ - - dt = (np.datetime64('1970-01-01T00:00:00', 's') - - np.datetime64(get_epoch(), 's')).astype(float) - - return (dt + np.asarray(e)) / SEC_PER_DAY - - -@_api.deprecated("3.5", alternative="`num2date(e).timestamp()<.num2date>`") -def num2epoch(d): - """ - Convert days since Matplotlib epoch to UNIX time. - - Parameters - ---------- - d : list of floats - Time in days since Matplotlib epoch (see `~.dates.get_epoch()`). - - Returns - ------- - `numpy.array` - Time in seconds since 1970-01-01. - """ - dt = (np.datetime64('1970-01-01T00:00:00', 's') - - np.datetime64(get_epoch(), 's')).astype(float) - - 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): diff --git a/lib/matplotlib/pylab.py b/lib/matplotlib/pylab.py index a9e30cfcd185..289aa9050e0c 100644 --- a/lib/matplotlib/pylab.py +++ b/lib/matplotlib/pylab.py @@ -16,8 +16,7 @@ import matplotlib as mpl from matplotlib.dates import ( - date2num, num2date, datestr2num, drange, epoch2num, - num2epoch, DateFormatter, DateLocator, + date2num, num2date, datestr2num, drange, DateFormatter, DateLocator, RRuleLocator, YearLocator, MonthLocator, WeekdayLocator, DayLocator, HourLocator, MinuteLocator, SecondLocator, rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY, diff --git a/lib/matplotlib/tests/test_dates.py b/lib/matplotlib/tests/test_dates.py index fc5eed7f2856..5985b6135119 100644 --- a/lib/matplotlib/tests/test_dates.py +++ b/lib/matplotlib/tests/test_dates.py @@ -1240,19 +1240,6 @@ def test_change_interval_multiples(): assert ax.get_xticklabels()[1].get_text() == 'Feb 01 2020' -def test_epoch2num(): - with _api.suppress_matplotlib_deprecation_warning(): - mdates._reset_epoch_test_example() - mdates.set_epoch('0000-12-31') - assert mdates.epoch2num(86400) == 719164.0 - assert mdates.num2epoch(719165.0) == 86400 * 2 - # set back to the default - mdates._reset_epoch_test_example() - mdates.set_epoch('1970-01-01T00:00:00') - assert mdates.epoch2num(86400) == 1.0 - assert mdates.num2epoch(2.0) == 86400 * 2 - - def test_julian2num(): mdates._reset_epoch_test_example() mdates.set_epoch('0000-12-31') diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index dfacdf4aead9..9e6865697194 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -196,21 +196,6 @@ def create_dummy_axis(self, **kwargs): if self.axis is None: self.axis = _DummyAxis(**kwargs) - @_api.deprecated("3.5", alternative="`.Axis.set_view_interval`") - def set_view_interval(self, vmin, vmax): - self.axis.set_view_interval(vmin, vmax) - - @_api.deprecated("3.5", alternative="`.Axis.set_data_interval`") - def set_data_interval(self, vmin, vmax): - self.axis.set_data_interval(vmin, vmax) - - @_api.deprecated( - "3.5", - alternative="`.Axis.set_view_interval` and `.Axis.set_data_interval`") - def set_bounds(self, vmin, vmax): - self.set_view_interval(vmin, vmax) - self.set_data_interval(vmin, vmax) - class Formatter(TickHelper): """