From b32b386cafc809a546a4b4fa891fa428355ac520 Mon Sep 17 00:00:00 2001 From: AndyXi163 <144465361+AndyXi163@users.noreply.github.com> Date: Wed, 6 Dec 2023 01:51:00 -0500 Subject: [PATCH 1/4] Attempted to add test_pcolorfast in test_datetime.py --- lib/matplotlib/tests/test_datetime.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 39a160d8ff03..f846f9c775eb 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -5,6 +5,7 @@ import matplotlib.pyplot as plt import matplotlib as mpl +import matplotlib.dates as dt class TestDatetimePlotting: @@ -516,11 +517,28 @@ def test_pcolor(self): fig, ax = plt.subplots() ax.pcolor(...) - @pytest.mark.xfail(reason="Test for pcolorfast not written yet") @mpl.style.context("default") def test_pcolorfast(self): + np.random.seed(19680801) + + ''' + Directly inputting either datetime.datetime or numpy.datetime64 without using date2num() seems to always generate compile errors for pcolorfast(). + I have used date2num() to ensure that the graph prints correctly despite that such operations may defy the purpose of conducting such tests. + ''' + basedate_x = datetime.datetime(2023, 12, 6, 1, 30, 30) + basedate_y = datetime.datetime(2024, 5, 5, 12, 15, 45) + dates_x = [dt.date2num(basedate_x + datetime.timedelta(days=1*i, hours=6*i, minutes=20*i,seconds=0)) for i in range(10)] + dates_y = [dt.date2num(basedate_y + datetime.timedelta(days=1*i, hours=8*i, minutes=30*i,seconds=0)) for i in range(10)] + data = np.random.rand(0, 100) + fig, ax = plt.subplots() ax.pcolorfast(...) + pc = ax.pcolorfast(dates_x, dates_y, data) + + ax.set_xlabel('Sample datetime') + ax.set_ylabel('Sample data') + ax.set_title('Sample test case for pcolorfast()') + plt.show() @pytest.mark.xfail(reason="Test for pcolormesh not written yet") @mpl.style.context("default") From b2e12e99ae3bf0070d25ccbb8c6509b1292b6d75 Mon Sep 17 00:00:00 2001 From: AndyXi163 <144465361+AndyXi163@users.noreply.github.com> Date: Wed, 6 Dec 2023 02:03:24 -0500 Subject: [PATCH 2/4] Removed placeholder. --- 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 f846f9c775eb..af34e9c1ca69 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -532,7 +532,6 @@ def test_pcolorfast(self): data = np.random.rand(0, 100) fig, ax = plt.subplots() - ax.pcolorfast(...) pc = ax.pcolorfast(dates_x, dates_y, data) ax.set_xlabel('Sample datetime') From 3966ad4c31e9ac1cd16aa5169ad4d537fa5e8932 Mon Sep 17 00:00:00 2001 From: AndyXi163 <144465361+AndyXi163@users.noreply.github.com> Date: Wed, 6 Dec 2023 02:08:01 -0500 Subject: [PATCH 3/4] Fixed formatting. --- lib/matplotlib/tests/test_datetime.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index af34e9c1ca69..a5fa0f3804db 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -522,13 +522,15 @@ def test_pcolorfast(self): np.random.seed(19680801) ''' - Directly inputting either datetime.datetime or numpy.datetime64 without using date2num() seems to always generate compile errors for pcolorfast(). - I have used date2num() to ensure that the graph prints correctly despite that such operations may defy the purpose of conducting such tests. + Directly inputting either datetime.datetime or numpy.datetime64 + without using date2num() seems to always generate compile errors for pcolorfast(). + I have used date2num() to ensure that the graph prints correctly + despite that such operations may defy the purpose of conducting such tests. ''' basedate_x = datetime.datetime(2023, 12, 6, 1, 30, 30) basedate_y = datetime.datetime(2024, 5, 5, 12, 15, 45) - dates_x = [dt.date2num(basedate_x + datetime.timedelta(days=1*i, hours=6*i, minutes=20*i,seconds=0)) for i in range(10)] - dates_y = [dt.date2num(basedate_y + datetime.timedelta(days=1*i, hours=8*i, minutes=30*i,seconds=0)) for i in range(10)] + dates_x = [dt.date2num(basedate_x + datetime.timedelta(days=1*i, hours=6*i, minutes=20*i)) for i in range(10)] + dates_y = [dt.date2num(basedate_y + datetime.timedelta(days=1*i, hours=8*i, minutes=30*i)) for i in range(10)] data = np.random.rand(0, 100) fig, ax = plt.subplots() From 434c41af2c0c6cdef3271ca3539724d747182e2a Mon Sep 17 00:00:00 2001 From: AndyXi163 <144465361+AndyXi163@users.noreply.github.com> Date: Fri, 22 Dec 2023 11:26:50 -0500 Subject: [PATCH 4/4] Removed the plt.show() call to reduce errors --- 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 f7b5f1241265..b8015b32fdd4 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -568,7 +568,6 @@ def test_pcolorfast(self): ax.set_xlabel('Sample datetime') ax.set_ylabel('Sample data') ax.set_title('Sample test case for pcolorfast()') - plt.show() @pytest.mark.xfail(reason="Test for pcolormesh not written yet") @mpl.style.context("default")
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: