From 71e1c63a6028aa24ccef1eb5138ba8a433c4eb8a Mon Sep 17 00:00:00 2001 From: CozyFrog Date: Thu, 26 Oct 2023 16:20:26 -0400 Subject: [PATCH 1/3] Add test_hlines to test_datetimes.py --- lib/matplotlib/tests/test_datetime.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index c9455d450b70..3cac147c002f 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -218,11 +218,27 @@ def test_hist2d(self): fig, ax = plt.subplots() ax.hist2d(...) - @pytest.mark.xfail(reason="Test for hlines not written yet") @mpl.style.context("default") def test_hlines(self): - fig, ax = plt.subplots() - ax.hlines(...) + mpl.rcParams["date.converter"] = 'concise' + fig, axs = plt.subplots(2, 3, layout='constrained') + dateStrs = ['2023-03-08', + '2023-04-09', + '2023-05-13', + '2023-07-28', + '2023-12-24'] + dates = [datetime.datetime(2023, m*2, 10) for m in range(1, 6)] + npDates = [np.datetime64(s) for s in dateStrs] + axs[0, 0].hlines(y=dates, + xmin=[0.1, 0.2, 0.3, 0.4, 0.5], + xmax=[0.5, 0.6, 0.7, 0.8, 0.9]) + axs[0, 1].hlines(y=dates, xmin=0.2, xmax=0.8) + axs[0, 2].hlines(dates, xmin=0, xmax=1) + axs[1, 0].hlines(y=npDates, + xmin=[0.5, 0.6, 0.7, 0.8, 0.9], + xmax=[0.1, 0.2, 0.3, 0.4, 0.5]) + axs[1, 1].hlines(y=npDates, xmin=0.45, xmax=0.65) + axs[1, 2].hlines(npDates, xmin=0, xmax=1) @pytest.mark.xfail(reason="Test for imshow not written yet") @mpl.style.context("default") From f4af444aa5721cd2aa7c5f14e1bebd208383efa3 Mon Sep 17 00:00:00 2001 From: CozyFrog Date: Tue, 31 Oct 2023 13:26:03 -0400 Subject: [PATCH 2/3] Add datetime arguments for xmin and xmax --- lib/matplotlib/tests/test_datetime.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 3cac147c002f..184962d12564 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -228,17 +228,27 @@ def test_hlines(self): '2023-07-28', '2023-12-24'] dates = [datetime.datetime(2023, m*2, 10) for m in range(1, 6)] + date_start = [datetime.datetime(2023, 6, d) for d in range(5, 30, 5)] + date_end = [datetime.datetime(2023, 7, d) for d in range(5, 30, 5)] npDates = [np.datetime64(s) for s in dateStrs] axs[0, 0].hlines(y=dates, xmin=[0.1, 0.2, 0.3, 0.4, 0.5], xmax=[0.5, 0.6, 0.7, 0.8, 0.9]) - axs[0, 1].hlines(y=dates, xmin=0.2, xmax=0.8) - axs[0, 2].hlines(dates, xmin=0, xmax=1) + axs[0, 1].hlines(dates, + xmin=datetime.datetime(2020, 5, 10), + xmax=datetime.datetime(2020, 5, 31)) + axs[0, 2].hlines(dates, + xmin=date_start, + xmax=date_end) axs[1, 0].hlines(y=npDates, xmin=[0.5, 0.6, 0.7, 0.8, 0.9], xmax=[0.1, 0.2, 0.3, 0.4, 0.5]) - axs[1, 1].hlines(y=npDates, xmin=0.45, xmax=0.65) - axs[1, 2].hlines(npDates, xmin=0, xmax=1) + axs[1, 2].hlines(y=npDates, + xmin=date_start, + xmax=date_end) + axs[1, 1].hlines(npDates, + xmin=datetime.datetime(2020, 5, 10), + xmax=datetime.datetime(2020, 5, 31)) @pytest.mark.xfail(reason="Test for imshow not written yet") @mpl.style.context("default") From e3abb2e7d64cdcea8a216727a714ec7d8b359087 Mon Sep 17 00:00:00 2001 From: CozyFrog Date: Wed, 1 Nov 2023 11:26:00 -0400 Subject: [PATCH 3/3] Added test for singular float xmin/xmax arguments --- lib/matplotlib/tests/test_datetime.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 184962d12564..a7d4f18080f4 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -221,7 +221,7 @@ def test_hist2d(self): @mpl.style.context("default") def test_hlines(self): mpl.rcParams["date.converter"] = 'concise' - fig, axs = plt.subplots(2, 3, layout='constrained') + fig, axs = plt.subplots(2, 4, layout='constrained') dateStrs = ['2023-03-08', '2023-04-09', '2023-05-13', @@ -240,6 +240,9 @@ def test_hlines(self): axs[0, 2].hlines(dates, xmin=date_start, xmax=date_end) + axs[0, 3].hlines(dates, + xmin=0.45, + xmax=0.65) axs[1, 0].hlines(y=npDates, xmin=[0.5, 0.6, 0.7, 0.8, 0.9], xmax=[0.1, 0.2, 0.3, 0.4, 0.5]) @@ -249,6 +252,9 @@ def test_hlines(self): axs[1, 1].hlines(npDates, xmin=datetime.datetime(2020, 5, 10), xmax=datetime.datetime(2020, 5, 31)) + axs[1, 3].hlines(npDates, + xmin=0.45, + xmax=0.65) @pytest.mark.xfail(reason="Test for imshow not written yet") @mpl.style.context("default")