8000 Backport PR #17983: FIX: undeprecate and update num2epoch/epoch2num · matplotlib/matplotlib@b50fa14 · GitHub
[go: up one dir, main page]

Skip to content

Commit b50fa14

Browse files
committed
Backport PR #17983: FIX: undeprecate and update num2epoch/epoch2num
1 parent ef7feb1 commit b50fa14

File tree

2 files changed

+9
-51
lines changed

2 files changed

+9
-51
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
Deprecations
22
------------
3+
4+
Reverted deprecation of `~.dates.num2epoch` and `~.dates.epoch2num`
5+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
7+
These two functions were deprecated in 3.3.0, and did not return
8+
an accurate Matplotlib datenum relative to the new Matplotlib epoch
9+
handling (`~.dates.get_epoch` and :rc:`date.epoch`). This version
10+
reverts the deprecation and fixes those functions to work with
11+
`~.dates.get_epoch`.

lib/matplotlib/tests/test_dates.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -949,57 +949,6 @@ def test_change_epoch():
949949
0.5)
950950

951951

952-
def test_warn_notintervals():
953-
dates = np.arange('2001-01-10', '2001-03-04', dtype='datetime64[D]')
954-
locator = mdates.AutoDateLocator(interval_multiples=False)
955-
locator.intervald[3] = [2]
956-
locator.create_dummy_axis()
957-
locator.set_view_interval(mdates.date2num(dates[0]),
958-
mdates.date2num(dates[-1]))
959-
with pytest.warns(UserWarning, match="AutoDateLocator was unable") as rec:
960-
locs = locator()
961-
962-
963-
def test_change_converter():
964-
plt.rcParams['date.converter'] = 'concise'
965-
dates = np.arange('2020-01-01', '2020-05-01', dtype='datetime64[D]')
966-
fig, ax = plt.subplots()
967-
968-
ax.plot(dates, np.arange(len(dates)))
969-
fig.canvas.draw()
970-
assert ax.get_xticklabels()[0].get_text() == 'Jan'
971-
assert ax.get_xticklabels()[1].get_text() == '15'
972-
973-
plt.rcParams['date.converter'] = 'auto'
974-
fig, ax = plt.subplots()
975-
976-
ax.plot(dates, np.arange(len(dates)))
977-
fig.canvas.draw()
978-
assert ax.get_xticklabels()[0].get_text() == 'Jan 01 2020'
979-
assert ax.get_xticklabels()[1].get_text() == 'Jan 15 2020'
980-
with pytest.warns(UserWarning) as rec:
981-
plt.rcParams['date.converter'] = 'boo'
982-
983-
984-
def test_change_interval_multiples():
985-
plt.rcParams['date.interval_multiples'] = False
986-
dates = np.arange('2020-01-10', '2020-05-01', dtype='datetime64[D]')
987-
fig, ax = plt.subplots()
988-
989-
ax.plot(dates, np.arange(len(dates)))
990-
fig.canvas.draw()
991-
assert ax.get_xticklabels()[0].get_text() == 'Jan 10 2020'
992-
assert ax.get_xticklabels()[1].get_text() == 'Jan 24 2020'
993-
994-
plt.rcParams['date.interval_multiples'] = 'True'
995-
fig, ax = plt.subplots()
996-
997-
ax.plot(dates, np.arange(len(dates)))
998-
fig.canvas.draw()
999-
assert ax.get_xticklabels()[0].get_text() == 'Jan 15 2020'
1000-
assert ax.get_xticklabels()[1].get_text() == 'Feb 01 2020'
1001-
1002-
1003952
def test_epoch2num():
1004953
mdates._reset_epoch_test_example()
1005954
mdates.set_epoch('0000-12-31')

0 commit comments

Comments
 (0)
0