From 0cd39c14d8eacf0a5deb4ac79b9f5043126e89ab Mon Sep 17 00:00:00 2001 From: rawwash Date: Wed, 29 Nov 2023 09:28:49 -0500 Subject: [PATCH 1/3] added test case for test_bxp --- lib/matplotlib/tests/test_datetime.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 316be793e47c..ee266476f80f 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -183,11 +183,25 @@ def test_broken_barh(self): fig, ax = plt.subplots() ax.broken_barh(...) - @pytest.mark.xfail(reason="Test for bxp not written yet") @mpl.style.context("default") def test_bxp(self): + mpl.rcParams["date.converter"] = 'concise' fig, ax = plt.subplots() - ax.bxp(...) + to_mpl_date = mpl.dates.date2num + data = [{ + "med": to_mpl_date(datetime.datetime(2020, 1, 15)), + "q1": to_mpl_date(datetime.datetime(2020, 1, 10)), + "q3": to_mpl_date(datetime.datetime(2020, 1, 20)), + "whislo": to_mpl_date(datetime.datetime(2020, 1, 5)), + "whishi": to_mpl_date(datetime.datetime(2020, 1, 25)), + "fliers": [ + to_mpl_date(datetime.datetime(2020, 1, 3)), + to_mpl_date(datetime.datetime(2020, 1, 27)) + ] + }] + ax.bxp(data) + ax.yaxis.set_major_formatter(mpl.dates.DateFormatter("%Y-%m-%d")) + ax.set_title('Box plot with datetime data') @pytest.mark.xfail(reason="Test for clabel not written yet") @mpl.style.context("default") From 8082072d421e0163aa30937d4c0ae3739c80a60e Mon Sep 17 00:00:00 2001 From: rawwash Date: Wed, 29 Nov 2023 16:30:15 -0500 Subject: [PATCH 2/3] adding datetime functionality --- lib/matplotlib/tests/test_datetime.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index ee266476f80f..671eb85040b3 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -187,21 +187,21 @@ def test_broken_barh(self): def test_bxp(self): mpl.rcParams["date.converter"] = 'concise' fig, ax = plt.subplots() - to_mpl_date = mpl.dates.date2num data = [{ - "med": to_mpl_date(datetime.datetime(2020, 1, 15)), - "q1": to_mpl_date(datetime.datetime(2020, 1, 10)), - "q3": to_mpl_date(datetime.datetime(2020, 1, 20)), - "whislo": to_mpl_date(datetime.datetime(2020, 1, 5)), - "whishi": to_mpl_date(datetime.datetime(2020, 1, 25)), + "med": datetime.datetime(2020, 1, 15), + "q1": datetime.datetime(2020, 1, 10), + "q3": datetime.datetime(2020, 1, 20), + "whislo": datetime.datetime(2020, 1, 5), + "whishi": datetime.datetime(2020, 1, 25), "fliers": [ - to_mpl_date(datetime.datetime(2020, 1, 3)), - to_mpl_date(datetime.datetime(2020, 1, 27)) + datetime.datetime(2020, 1, 3), + datetime.datetime(2020, 1, 27) ] }] - ax.bxp(data) - ax.yaxis.set_major_formatter(mpl.dates.DateFormatter("%Y-%m-%d")) + ax.bxp(data, vert=False) + ax.xaxis.set_major_formatter(mpl.dates.DateFormatter("%Y-%m-%d")) ax.set_title('Box plot with datetime data') + plt.show() @pytest.mark.xfail(reason="Test for clabel not written yet") @mpl.style.context("default") From 64080840bff606a1f84cc0037b32d15e4446f531 Mon Sep 17 00:00:00 2001 From: rawwash Date: Wed, 29 Nov 2023 16:52:26 -0500 Subject: [PATCH 3/3] removing plt.show() --- lib/matplotlib/tests/test_datetime.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 671eb85040b3..48bfd76e26b1 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -201,7 +201,6 @@ def test_bxp(self): ax.bxp(data, vert=False) ax.xaxis.set_major_formatter(mpl.dates.DateFormatter("%Y-%m-%d")) ax.set_title('Box plot with datetime data') - plt.show() @pytest.mark.xfail(reason="Test for clabel not written yet") @mpl.style.context("default")