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

Skip to content

Commit 7ae4a36

Browse files
committed
Backport PR #12678: FIX: properly set tz for YearLocator
1 parent 32d4164 commit 7ae4a36

File tree

1 file changed

+0
-51
lines changed

1 file changed

+0
-51
lines changed

lib/matplotlib/tests/test_dates.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -475,57 +475,6 @@ def _create_auto_date_locator(date1, date2):
475475
assert list(map(str, mdates.num2date(locator()))) == expected
476476

477477

478-
def test_concise_formatter():
479-
def _create_auto_date_locator(date1, date2):
480-
fig, ax = plt.subplots()
481-
482-
locator = mdates.AutoDateLocator(interval_multiples=True)
483-
formatter = mdates.ConciseDateFormatter(locator)
484-
ax.yaxis.set_major_locator(locator)
485-
ax.yaxis.set_major_formatter(formatter)
486-
ax.set_ylim(date1, date2)
487-
fig.canvas.draw()
488-
sts = []
489-
for st in ax.get_yticklabels():
490-
sts += [st.get_text()]
491-
return sts
492-
493-
d1 = datetime.datetime(1997, 1, 1)
494-
results = ([datetime.timedelta(weeks=52 * 200),
495-
[str(t) for t in range(1980, 2201, 20)]
496-
],
497-
[datetime.timedelta(weeks=52),
498-
['1997', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
499-
'Sep', 'Oct', 'Nov', 'Dec']
500-
],
501-
[datetime.timedelta(days=141),
502-
['Jan', '22', 'Feb', '22', 'Mar', '22', 'Apr', '22',
503-
'May', '22']
504-
],
505-
[datetime.timedelta(days=40),
506-
['Jan', '05', '09', '13', '17', '21', '25', '29', 'Feb',
507-
'05', '09']
508-
],
509-
[datetime.timedelta(hours=40),
510-
['Jan-01', '04:00', '08:00', '12:00', '16:00', '20:00',
511-
'Jan-02', '04:00', '08:00', '12:00', '16:00']
512-
],
513-
[datetime.timedelta(minutes=20),
514-
['00:00', '00:05', '00:10', '00:15', '00:20']
515-
],
516-
[datetime.timedelta(seconds=40),
517-
['00:00', '05', '10', '15', '20', '25', '30', '35', '40']
518-
],
519-
[datetime.timedelta(seconds=2),
520-
['59.5', '00:00', '00.5', '01.0', '01.5', '02.0', '02.5']
521-
],
522-
)
523-
for t_delta, expected in results:
524-
d2 = d1 + t_delta
525-
strings = _create_auto_date_locator(d1, d2)
526-
assert strings == expected
527-
528-
529478
def test_auto_date_locator_intmult_tz():
530479
def _create_auto_date_locator(date1, date2, tz):
531480
locator = mdates.AutoDateLocator(interval_multiples=True, tz=tz)

0 commit comments

Comments
 (0)