MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_concise_formatter_tz

Function test_concise_formatter_tz

lib/matplotlib/tests/test_dates.py:845–883  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

843
844
845def test_concise_formatter_tz():
846 def _create_auto_date_locator(date1, date2, tz):
847 fig, ax = plt.subplots()
848
849 locator = mdates.AutoDateLocator(interval_multiples=True)
850 formatter = mdates.ConciseDateFormatter(locator, tz=tz)
851 ax.yaxis.set_major_locator(locator)
852 ax.yaxis.set_major_formatter(formatter)
853 ax.set_ylim(date1, date2)
854 fig.canvas.draw()
855 sts = [st.get_text() for st in ax.get_yticklabels()]
856 return sts, ax.yaxis.get_offset_text().get_text()
857
858 d1 = datetime.datetime(1997, 1, 1).replace(tzinfo=datetime.timezone.utc)
859 results = ([datetime.timedelta(hours=40),
860 ['03:00', '07:00', '11:00', '15:00', '19:00', '23:00',
861 '03:00', '07:00', '11:00', '15:00', '19:00'],
862 "1997-Jan-02"
863 ],
864 [datetime.timedelta(minutes=20),
865 ['03:00', '03:05', '03:10', '03:15', '03:20'],
866 "1997-Jan-01"
867 ],
868 [datetime.timedelta(seconds=40),
869 ['03:00', '05', '10', '15', '20', '25', '30', '35', '40'],
870 "1997-Jan-01 03:00"
871 ],
872 [datetime.timedelta(seconds=2),
873 ['59.5', '03:00', '00.5', '01.0', '01.5', '02.0', '02.5'],
874 "1997-Jan-01 03:00"
875 ],
876 )
877
878 new_tz = datetime.timezone(datetime.timedelta(hours=3))
879 for t_delta, expected_strings, expected_offset in results:
880 d2 = d1 + t_delta
881 strings, offset = _create_auto_date_locator(d1, d2, new_tz)
882 assert strings == expected_strings
883 assert offset == expected_offset
884
885
886def test_auto_date_locator_intmult_tz():

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…