Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 76dcd51

Browse files
committed
Expire deprecations in dates and ticker
1 parent 924e210 commit 76dcd51

File tree

7 files changed

+24
-93
lines changed

7 files changed

+24
-93
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
``epoch2num`` and ``num2epoch`` are removed
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
These methods convert from unix timestamps to matplotlib floats, but are not
5+
used internally to Matplotlib, and should not be needed by end users. To
6+
convert a unix timestamp to datetime, simply use
7+
`datetime.datetime.utcfromtimestamp`, or to use NumPy `~numpy.datetime64`
8+
``dt = np.datetime64(e*1e6, 'us')``.
9+
10+
11+
Locator and Formatter wrapper methods
12+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13+
14+
The ``set_view_interval``, ``set_data_interval`` and ``set_bounds`` methods of
15+
`.Locator`\s and `.Formatter`\s (and their common base class, TickHelper) are
16+
removed. Directly manipulate the view and data intervals on the underlying
17+
axis instead.

doc/api/prev_api_changes/api_changes_3.3.0/deprecations.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,8 @@ experimental and may change in the future.
545545
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
546546
... is deprecated.
547547

548-
`.epoch2num` and `.num2epoch` are deprecated
549-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
548+
``epoch2num`` and ``num2epoch` are deprecated
549+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
550550
These are unused and can be easily reproduced by other date tools.
551551
`.get_epoch` will return Matplotlib's epoch.
552552

doc/api/prev_api_changes/api_changes_3.3.1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ reverts the deprecation.
1515
Functions ``epoch2num`` and ``dates.julian2num`` use ``date.epoch`` rcParam
1616
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1717

18-
Now `~.dates.epoch2num` and (undocumented) ``julian2num`` return floating point
18+
Now ``epoch2num`` and (undocumented) ``julian2num`` return floating point
1919
days since `~.dates.get_epoch` as set by :rc:`date.epoch`, instead of
2020
floating point days since the old epoch of "0000-12-31T00:00:00". If
2121
needed, you can translate from the new to old values as

lib/matplotlib/dates.py

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,9 @@
187187
from matplotlib import _api, cbook, ticker, units
188188

189189
__all__ = ('datestr2num', 'date2num', 'num2date', 'num2timedelta', 'drange',
190-
'epoch2num', 'num2epoch', 'set_epoch', 'get_epoch', 'DateFormatter',
191-
'ConciseDateFormatter', 'AutoDateFormatter',
192-
'DateLocator', 'RRuleLocator', 'AutoDateLocator', 'YearLocator',
193-
'MonthLocator', 'WeekdayLocator',
190+
'set_epoch', 'get_epoch', 'DateFormatter', 'ConciseDateFormatter',
191+
'AutoDateFormatter', 'DateLocator', 'RRuleLocator',
192+
'AutoDateLocator', 'YearLocator', 'MonthLocator', 'WeekdayLocator',
194193
'DayLocator', 'HourLocator', 'MinuteLocator',
195194
'SecondLocator', 'MicrosecondLocator',
196195
'rrule', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU',
@@ -1737,16 +1736,6 @@ def set_axis(self, axis):
17371736
self._wrapped_locator.set_axis(axis)
17381737
return super().set_axis(axis)
17391738

1740-
@_api.deprecated("3.5", alternative="`.Axis.set_view_interval`")
1741-
def set_view_interval(self, vmin, vmax):
1742-
self._wrapped_locator.set_view_interval(vmin, vmax)
1743-
return super().set_view_interval(vmin, vmax)
1744-
1745-
@_api.deprecated("3.5", alternative="`.Axis.set_data_interval`")
1746-
def set_data_interval(self, vmin, vmax):
1747-
self._wrapped_locator.set_data_interval(vmin, vmax)
1748-
return super().set_data_interval(vmin, vmax)
1749-
17501739
def __call__(self):
17511740
# if no data have been set, this will tank with a ValueError
17521741
try:
@@ -1778,52 +1767,6 @@ def _get_interval(self):
17781767
return self._interval
17791768

17801769

1781-
@_api.deprecated(
1782-
"3.5",
1783-
alternative="``[date2num(datetime.utcfromtimestamp(t)) for t in e]`` or "
1784-
"numpy.datetime64 types")
1785-
def epoch2num(e):
1786-
"""
1787-
Convert UNIX time to days since Matplotlib epoch.
1788-
1789-
Parameters
1790-
----------
1791-
e : list of floats
1792-
Time in seconds since 1970-01-01.
1793-
1794-
Returns
1795-
-------
1796-
`numpy.array`
1797-
Time in days since Matplotlib epoch (see `~.dates.get_epoch()`).
1798-
"""
1799-
1800-
dt = (np.datetime64('1970-01-01T00:00:00', 's') -
1801-
np.datetime64(get_epoch(), 's')).astype(float)
1802-
1803-
return (dt + np.asarray(e)) / SEC_PER_DAY
1804-
1805-
1806-
@_api.deprecated("3.5", alternative="`num2date(e).timestamp()<.num2date>`")
1807-
def num2epoch(d):
1808-
"""
1809-
Convert days since Matplotlib epoch to UNIX time.
1810-
1811-
Parameters
1812-
----------
1813-
d : list of floats
1814-
Time in days since Matplotlib epoch (see `~.dates.get_epoch()`).
1815-
1816-
Returns
1817-
-------
1818-
`numpy.array`
1819-
Time in seconds since 1970-01-01.
1820-
"""
1821-
dt = (np.datetime64('1970-01-01T00:00:00', 's') -
1822-
np.datetime64(get_epoch(), 's')).astype(float)
1823-
1824-
return np.asarray(d) * SEC_PER_DAY - dt
1825-
1826-
18271770
@_api.deprecated("3.6", alternative="`AutoDateLocator` and `AutoDateFormatter`"
18281771
" or vendor the code")
18291772
def date_ticker_factory(span, tz=None, numticks=5):

lib/matplotlib/pylab.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
import matplotlib as mpl
1717

1818
from matplotlib.dates import (
19-
date2num, num2date, datestr2num, drange, epoch2num,
20-
num2epoch, DateFormatter, DateLocator,
19+
date2num, num2date, datestr2num, drange, DateFormatter, DateLocator,
2120
RRuleLocator, YearLocator, MonthLocator, WeekdayLocator, DayLocator,
2221
HourLocator, MinuteLocator, SecondLocator, rrule, MO, TU, WE, TH, FR,
2322
SA, SU, YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY,

lib/matplotlib/tests/test_dates.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,19 +1240,6 @@ def test_change_interval_multiples():
12401240
assert ax.get_xticklabels()[1].get_text() == 'Feb 01 2020'
12411241

12421242

1243-
def test_epoch2num():
1244-
with _api.suppress_matplotlib_deprecation_warning():
1245-
mdates._reset_epoch_test_example()
1246-
mdates.set_epoch('0000-12-31')
1247-
assert mdates.epoch2num(86400) == 719164.0
1248-
assert mdates.num2epoch(719165.0) == 86400 * 2
1249-
# set back to the default
1250-
mdates._reset_epoch_test_example()
1251-
mdates.set_epoch('1970-01-01T00:00:00')
1252-
assert mdates.epoch2num(86400) == 1.0
1253-
assert mdates.num2epoch(2.0) == 86400 * 2
1254-
1255-
12561243
def test_julian2num():
12571244
mdates._reset_epoch_test_example()
12581245
mdates.set_epoch('0000-12-31')

lib/matplotlib/ticker.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -196,21 +196,6 @@ def create_dummy_axis(self, **kwargs):
196196
if self.axis is None:
197197
self.axis = _DummyAxis(**kwargs)
198198

199-
@_api.deprecated("3.5", alternative="`.Axis.set_view_interval`")
200-
def set_view_interval(self, vmin, vmax):
201-
self.axis.set_view_interval(vmin, vmax)
202-
203-
@_api.deprecated("3.5", alternative="`.Axis.set_data_interval`")
204-
def set_data_interval(self, vmin, vmax):
205-
self.axis.set_data_interval(vmin, vmax)
206-
207-
@_api.deprecated(
208-
"3.5",
209-
alternative="`.Axis.set_view_interval` and `.Axis.set_data_interval`")
210-
def set_bounds(self, vmin, vmax):
211-
self.set_view_interval(vmin, vmax)
212-
self.set_data_interval(vmin, vmax)
213-
214199

215200
class Formatter(TickHelper):
216201
"""

0 commit comments

Comments
 (0)