From 50608b42aba04beace97558b9ea9594b3dd5bb93 Mon Sep 17 00:00:00 2001 From: YiLun Fan Date: Tue, 17 Oct 2023 14:50:24 +1100 Subject: [PATCH 1/4] Added the smoke testing for pie function --- lib/matplotlib/tests/test_datetime.py | 63 +++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index ef83b837348d..927acd94bd83 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -229,11 +229,68 @@ def test_matshow(self): fig, ax = plt.subplots() ax.matshow(...) - @pytest.mark.xfail(reason="Test for pie not written yet") @mpl.style.context("default") def test_pie(self): - fig, ax = plt.subplots() - ax.pcolor(...) + mpl.rcParams["date.converter"] = 'concise' + + start_date = datetime.datetime(2023,11,1) + delta = datetime.timedelta(days=1) + date_data = [start_date + i*delta for i in range(30)] + date_data_ymd = [date.strftime('%Y%m%d') for date in date_data] + date_data_ordinal = [date.toordinal() for date in date_data] + label_data = ["Date: "+str(date) for date in date_data_ymd] + color_data = ["#4B0082","#FF00FF","#6A5ACD","#6495ED","#00BFFF","#00FFFF","#00FA9A","#556B2F","#FFD700"] + explode_data = [] + for i in range(6): + if i%2==0: + explode_data_larger.append(0.1) + else: + explode_data_larger.append(0) + + explode_data_larger=[] + for i in range(30): + if i%2==0: + explode_data_larger.append(0.1) + else: + explode_data_larger.append(0) + + # Making the basic plot for testing + fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) + ax1.pie( + date_data_ordinal[0:6], + labels = label_data[0:6] + ) + ax2.pie( + date_data_ordinal[6:12], + labels = label_data[6:12], + colors = color_data[6:12] + ) + ax3.pie( + date_data_ordinal[0:6], + labels = label_data[0:6], + colors = color_data[0:6], + explode = explode_data + ) + + + # Making the plot with larger dataset for testing + fig, (ax4, ax5, ax6) = plt.subplots(3,1,constrained_layout=True) + ax4.pie( + date_data_ordinal, + labels = label_data + ) + ax5.pie( + date_data_ordinal, + labels = label_data, + colors = color_data + ) + ax6.pie( + date_data_ordinal, + labels = label_data, + colors = color_data, + explode = explode_data_larger + ) + @pytest.mark.xfail(reason="Test for pcolor not written yet") @mpl.style.context("default") From b6b9378092fff97e4f616b3c6e3029f3bcca8a1a Mon Sep 17 00:00:00 2001 From: YiLun Fan Date: Tue, 17 Oct 2023 15:04:33 +1100 Subject: [PATCH 2/4] Fixed some typos and mistakes in test code. --- 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 927acd94bd83..8800f1dcf80a 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -243,9 +243,9 @@ def test_pie(self): explode_data = [] for i in range(6): if i%2==0: - explode_data_larger.append(0.1) + explode_data.append(0.1) else: - explode_data_larger.append(0) + explode_data.append(0) explode_data_larger=[] for i in range(30): From 91d2eccfe293a85ae48426a6055730dfd41b0a76 Mon Sep 17 00:00:00 2001 From: YiLun Fan Date: Tue, 17 Oct 2023 15:08:30 +1100 Subject: [PATCH 3/4] added further comments --- lib/matplotlib/tests/test_datetime.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 8800f1dcf80a..6dcad64b0a22 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -232,7 +232,8 @@ def test_matshow(self): @mpl.style.context("default") def test_pie(self): mpl.rcParams["date.converter"] = 'concise' - + + # Preparing the input data for testing start_date = datetime.datetime(2023,11,1) delta = datetime.timedelta(days=1) date_data = [start_date + i*delta for i in range(30)] @@ -240,21 +241,21 @@ def test_pie(self): date_data_ordinal = [date.toordinal() for date in date_data] label_data = ["Date: "+str(date) for date in date_data_ymd] color_data = ["#4B0082","#FF00FF","#6A5ACD","#6495ED","#00BFFF","#00FFFF","#00FA9A","#556B2F","#FFD700"] - explode_data = [] + explode_data = [] # explode data for smaller dataset for i in range(6): if i%2==0: explode_data.append(0.1) else: explode_data.append(0) - explode_data_larger=[] + explode_data_larger=[] # explode data for larger dataset for i in range(30): if i%2==0: explode_data_larger.append(0.1) else: explode_data_larger.append(0) - # Making the basic plot for testing + # Making the basic plot with smaller dataset for testing fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) ax1.pie( date_data_ordinal[0:6], From 784e1583e10c59101491ba57b12c25db96c268f8 Mon Sep 17 00:00:00 2001 From: YiLun Fan Date: Tue, 17 Oct 2023 16:52:47 +1100 Subject: [PATCH 4/4] Remove the test for pie function --- lib/matplotlib/tests/test_datetime.py | 64 --------------------------- 1 file changed, 64 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 6dcad64b0a22..72701cd2d8cd 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -229,70 +229,6 @@ def test_matshow(self): fig, ax = plt.subplots() ax.matshow(...) - @mpl.style.context("default") - def test_pie(self): - mpl.rcParams["date.converter"] = 'concise' - - # Preparing the input data for testing - start_date = datetime.datetime(2023,11,1) - delta = datetime.timedelta(days=1) - date_data = [start_date + i*delta for i in range(30)] - date_data_ymd = [date.strftime('%Y%m%d') for date in date_data] - date_data_ordinal = [date.toordinal() for date in date_data] - label_data = ["Date: "+str(date) for date in date_data_ymd] - color_data = ["#4B0082","#FF00FF","#6A5ACD","#6495ED","#00BFFF","#00FFFF","#00FA9A","#556B2F","#FFD700"] - explode_data = [] # explode data for smaller dataset - for i in range(6): - if i%2==0: - explode_data.append(0.1) - else: - explode_data.append(0) - - explode_data_larger=[] # explode data for larger dataset - for i in range(30): - if i%2==0: - explode_data_larger.append(0.1) - else: - explode_data_larger.append(0) - - # Making the basic plot with smaller dataset for testing - fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) - ax1.pie( - date_data_ordinal[0:6], - labels = label_data[0:6] - ) - ax2.pie( - date_data_ordinal[6:12], - labels = label_data[6:12], - colors = color_data[6:12] - ) - ax3.pie( - date_data_ordinal[0:6], - labels = label_data[0:6], - colors = color_data[0:6], - explode = explode_data - ) - - - # Making the plot with larger dataset for testing - fig, (ax4, ax5, ax6) = plt.subplots(3,1,constrained_layout=True) - ax4.pie( - date_data_ordinal, - labels = label_data - ) - ax5.pie( - date_data_ordinal, - labels = label_data, - colors = color_data - ) - ax6.pie( - date_data_ordinal, - labels = label_data, - colors = color_data, - explode = explode_data_larger - ) - - @pytest.mark.xfail(reason="Test for pcolor not written yet") @mpl.style.context("default") def test_pcolor(self):