MCPcopy
hub / github.com/matplotlib/matplotlib / test_offset_changes

Function test_offset_changes

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

Source from the content-addressed store, hash-verified

677
678
679def test_offset_changes():
680 fig, ax = plt.subplots()
681
682 d1 = datetime.datetime(1997, 1, 1)
683 d2 = d1 + datetime.timedelta(weeks=520)
684
685 locator = mdates.AutoDateLocator()
686 formatter = mdates.ConciseDateFormatter(locator)
687 ax.xaxis.set_major_locator(locator)
688 ax.xaxis.set_major_formatter(formatter)
689
690 ax.plot([d1, d2], [0, 0])
691 fig.draw_without_rendering()
692 assert formatter.get_offset() == ''
693 ax.set_xlim(d1, d1 + datetime.timedelta(weeks=3))
694 fig.draw_without_rendering()
695 assert formatter.get_offset() == '1997-Jan'
696 ax.set_xlim(d1 + datetime.timedelta(weeks=7),
697 d1 + datetime.timedelta(weeks=30))
698 fig.draw_without_rendering()
699 assert formatter.get_offset() == '1997'
700 ax.set_xlim(d1, d1 + datetime.timedelta(weeks=520))
701 fig.draw_without_rendering()
702 assert formatter.get_offset() == ''
703
704
705@pytest.mark.parametrize('t_delta, expected', [

Callers

nothing calls this directly

Calls 7

get_offsetMethod · 0.95
subplotsMethod · 0.45
set_major_locatorMethod · 0.45
set_major_formatterMethod · 0.45
plotMethod · 0.45
set_xlimMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…