8000 TST: Add test which fails on main but passes on revert · matplotlib/matplotlib@7e1cf67 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e1cf67

Browse files
committed
TST: Add test which fails on main but passes on revert
1 parent 908795c commit 7e1cf67

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/matplotlib/tests/test_dates.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,27 @@ def test_concise_formatter_show_offset(t_delta, expected):
636636
assert formatter.get_offset() == expected
637637

638638

639+
def test_concise_converter_stays():
640+
# This test demonstrates problems introduced by gh-23417 (reverted in gh-25278)
641+
# In particular, downstream libraries like Pandas had their designated converters
642+
# overridden by actions like setting xlim (or plotting additional points using
643+
# stdlib/numpy dates and string date representation, which otherwise work fine with
644+
# their date converters)
645+
# While this is a bit of a toy example that would be unusual to see it demonstrates
646+
# the same ideas (namely having a valid converter already applied that is desired)
647+
# without introducing additional subclasses.
648+
# See also discussion at gh-25241 for how Pandas was affected
649+
x = [datetime.datetime(2000, 1, 1), datetime.datetime(2020, 2, 20)]
650+
y = [0, 1]
651+
fig, ax = plt.subplots()
652+
ax.plot(x, y)
653+
# Bypass Switchable date converter
654+
ax.xaxis.converter = conv = mdates.ConciseDateConverter()
655+
assert ax.xaxis.units is None
656+
ax.set_xlim(*x)
657+
assert ax.xaxis.converter == conv
658+
659+
639660
def test_offset_changes():
640661
fig, ax = plt.subplots()
641662

0 commit comments

Comments
 (0)
0