From 6075fc444f78f9605c0bc18a0fa7dd8b0ee16252 Mon Sep 17 00:00:00 2001 From: mliu08 Date: Sat, 28 Oct 2023 21:01:10 -0700 Subject: [PATCH 1/3] smoke test for axes.annotate in datetime --- lib/matplotlib/tests/test_datetime.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 05c94e5814e0..c8d63031b5ad 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -14,11 +14,25 @@ def test_acorr(self): fig, ax = plt.subplots() ax.acorr(...) - @pytest.mark.xfail(reason="Test for annotate not written yet") @mpl.style.context("default") def test_annotate(self): - fig, ax = plt.subplots() - ax.annotate(...) + mpl.rcParams["date.converter"] = 'concise' + fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1, layout="constrained") + + start_date = datetime.datetime(2023, 10, 1) + dates = [start_date + datetime.timedelta(days=i) for i in range(31)] + data = list(range(1, 32)) + test_text = "Test Text" + + ax1.plot(dates, data) + ax1.annotate(text=test_text, xy=(dates[15], data[15])) + ax2.plot(data, dates) + ax2.annotate(text=test_text, xy=(data[5], dates[26])) + ax3.plot(data, data) + ax3.annotate(text=test_text, xy=(data[15], data[3])) + ax4.plot(data, data) + ax4.annotate(text=test_text, xy=(data[5], data[30]), xytext=(data[1], data[7]), + arrowprops=dict(facecolor='red')) @pytest.mark.xfail(reason="Test for arrow not written yet") @mpl.style.context("default") From ff1f8cd7ae1ff5ea2d47700e6363b269323bea00 Mon Sep 17 00:00:00 2001 From: mliu08 Date: Sat, 28 Oct 2023 21:29:03 -0700 Subject: [PATCH 2/3] fixed tests using numeric data instead of dates --- lib/matplotlib/tests/test_datetime.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index c8d63031b5ad..424447ab1c3c 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -29,10 +29,10 @@ def test_annotate(self): ax2.plot(data, dates) ax2.annotate(text=test_text, xy=(data[5], dates[26])) ax3.plot(data, data) - ax3.annotate(text=test_text, xy=(data[15], data[3])) + ax3.annotate(text=test_text, xy=(dates[15], dates[3])) ax4.plot(data, data) - ax4.annotate(text=test_text, xy=(data[5], data[30]), xytext=(data[1], data[7]), - arrowprops=dict(facecolor='red')) + ax4.annotate(text=test_text, xy=(dates[5], dates[30]), + xytext=(dates[1], dates[7]), arrowprops=dict(facecolor='red')) @pytest.mark.xfail(reason="Test for arrow not written yet") @mpl.style.context("default") From a5b5995d1e85f5c14f66a50d53f6e714bdc69d10 Mon Sep 17 00:00:00 2001 From: mliu08 Date: Sat, 28 Oct 2023 21:43:02 -0700 Subject: [PATCH 3/3] smoke test for axes.annotate in test.datetime --- lib/matplotlib/tests/test_datetime.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 424447ab1c3c..6df829ac6a89 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -28,9 +28,9 @@ def test_annotate(self): ax1.annotate(text=test_text, xy=(dates[15], data[15])) ax2.plot(data, dates) ax2.annotate(text=test_text, xy=(data[5], dates[26])) - ax3.plot(data, data) + ax3.plot(dates, dates) ax3.annotate(text=test_text, xy=(dates[15], dates[3])) - ax4.plot(data, data) + ax4.plot(dates, dates) ax4.annotate(text=test_text, xy=(dates[5], dates[30]), xytext=(dates[1], dates[7]), arrowprops=dict(facecolor='red'))