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

Function test_concise_converter_stays

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

Source from the content-addressed store, hash-verified

654
655
656def test_concise_converter_stays():
657 # This test demonstrates problems introduced by gh-23417 (reverted in gh-25278)
658 # In particular, downstream libraries like Pandas had their designated converters
659 # overridden by actions like setting xlim (or plotting additional points using
660 # stdlib/numpy dates and string date representation, which otherwise work fine with
661 # their date converters)
662 # While this is a bit of a toy example that would be unusual to see it demonstrates
663 # the same ideas (namely having a valid converter already applied that is desired)
664 # without introducing additional subclasses.
665 # See also discussion at gh-25219 for how Pandas was affected
666 x = [datetime.datetime(2000, 1, 1), datetime.datetime(2020, 2, 20)]
667 y = [0, 1]
668 fig, ax = plt.subplots()
669 ax.plot(x, y)
670 # Bypass Switchable date converter
671 conv = mdates.ConciseDateConverter()
672 with pytest.warns(UserWarning, match="already has a converter"):
673 ax.xaxis.set_converter(conv)
674 assert ax.xaxis.units is None
675 ax.set_xlim(*x)
676 assert ax.xaxis.get_converter() == conv
677
678
679def test_offset_changes():

Callers

nothing calls this directly

Calls 5

set_converterMethod · 0.80
subplotsMethod · 0.45
plotMethod · 0.45
set_xlimMethod · 0.45
get_converterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…