From 40e8132e54c93ae87d5176dbb51e24c49ffb03e2 Mon Sep 17 00:00:00 2001 From: Nidaa Rabah <136858218+nidaa-7@users.noreply.github.com> Date: Wed, 29 Nov 2023 08:35:43 +0000 Subject: [PATCH 1/4] added a test for fill in test_datetime.py --- .gitignore | 3 +++ lib/matplotlib/tests/test_datetime.py | 30 ++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 99e7a628cffd..ee9652442b7a 100644 --- a/.gitignore +++ b/.gitignore @@ -114,3 +114,6 @@ lib/matplotlib/backends/web_backend/node_modules/ lib/matplotlib/backends/web_backend/package-lock.json LICENSE/LICENSE_QHULL + +# My virtual environment # +/venv/ diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 316be793e47c..2cade854e3dd 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -266,11 +266,35 @@ def test_eventplot(self): fig, ax = plt.subplots() ax.eventplot(...) - @pytest.mark.xfail(reason="Test for fill not written yet") @mpl.style.context("default") def test_fill(self): - fig, ax = plt.subplots() - ax.fill(...) + mpl.rcParams["date.converter"] = "concise" + fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1, layout="constrained") + + # Generate datetime for x-axis + x_base_date = datetime.datetime(2023, 1, 1) + x_dates = [x_base_date] + for _ in range(1, 5): + x_base_date += datetime.timedelta(days=np.random.randint(1, 5)) + x_dates.append(x_base_date) + + # Generate datetime for y-axis + y_base_date = datetime.datetime(2023, 1, 1) + y_dates = [y_base_date] + for _ in range(1, 5): + y_base_date += datetime.timedelta(days=np.random.randint(1, 5)) + y_dates.append(y_base_date) + + x_values = np.random.rand(5) * 5 + y_values = np.random.rand(5) * 5 - 2 # Random y-values between -2 and 3 + + # Plot filled polygons on each subplot + ax1.fill(x_dates, y_values) + ax2.fill(x_values, y_dates) + ax3.fill(x_values, y_values) + ax4.fill(x_dates, y_dates) + + plt.savefig("test_fill_output.png") @pytest.mark.xfail(reason="Test for fill_between not written yet") @mpl.style.context("default") From 7de0d462061fd6f307bb39836a4a146940874f82 Mon Sep 17 00:00:00 2001 From: Nidaa Rabah <136858218+nidaa-7@users.noreply.github.com> Date: Thu, 30 Nov 2023 04:10:23 +0000 Subject: [PATCH 2/4] Removed saving the picture from test code. --- lib/matplotlib/tests/test_datetime.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 2cade854e3dd..d998800e2096 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -271,14 +271,12 @@ def test_fill(self): mpl.rcParams["date.converter"] = "concise" fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1, layout="constrained") - # Generate datetime for x-axis x_base_date = datetime.datetime(2023, 1, 1) x_dates = [x_base_date] for _ in range(1, 5): x_base_date += datetime.timedelta(days=np.random.randint(1, 5)) x_dates.append(x_base_date) - # Generate datetime for y-axis y_base_date = datetime.datetime(2023, 1, 1) y_dates = [y_base_date] for _ in range(1, 5): @@ -286,16 +284,13 @@ def test_fill(self): y_dates.append(y_base_date) x_values = np.random.rand(5) * 5 - y_values = np.random.rand(5) * 5 - 2 # Random y-values between -2 and 3 + y_values = np.random.rand(5) * 5 - 2 - # Plot filled polygons on each subplot ax1.fill(x_dates, y_values) ax2.fill(x_values, y_dates) ax3.fill(x_values, y_values) ax4.fill(x_dates, y_dates) - plt.savefig("test_fill_output.png") - @pytest.mark.xfail(reason="Test for fill_between not written yet") @mpl.style.context("default") def test_fill_between(self): From 6322cc977ceb8e18c3b536c00b48f66884673097 Mon Sep 17 00:00:00 2001 From: Nidaa Rabah <136858218+nidaa-7@users.noreply.github.com> Date: Sun, 3 Dec 2023 23:29:30 +0000 Subject: [PATCH 3/4] Added test for axes.pcolormesh --- 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 d998800e2096..4ec64147088c 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -430,11 +430,27 @@ def test_pcolorfast(self): fig, ax = plt.subplots() ax.pcolorfast(...) - @pytest.mark.xfail(reason="Test for pcolormesh not written yet") @mpl.style.context("default") def test_pcolormesh(self): - fig, ax = plt.subplots() - ax.pcolormesh(...) + fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1, layout="constrained") + + np.random.seed(19680801) + + x_base_date = datetime.datetime(2023, 1, 1) + x_dates = [x_base_date + datetime.timedelta(days=i) for i in range(5)] + + y_base_date = datetime.datetime(2023, 1, 1) + y_dates = [y_base_date + datetime.timedelta(days=i) for i in range(5)] + + x_timestamps = [date.timestamp() for date in x_dates] + y_timestamps = [date.timestamp() for date in y_dates] + + data = np.random.rand(len(x_dates), len(y_dates)) + + ax1.pcolormesh(x_dates, y_dates, data, cmap='viridis') + ax2.pcolormesh(x_dates, y_timestamps, data, cmap='viridis') + ax3.pcolormesh(x_timestamps, y_dates, data, cmap='viridis') + ax4.pcolormesh(x_timestamps, y_timestamps, data, cmap='viridis') @mpl.style.context("default") def test_plot(self): From 6f4e568279989094b40dc0dff80291a8476d62e8 Mon Sep 17 00:00:00 2001 From: Nidaa Rabah <136858218+nidaa-7@users.noreply.github.com> Date: Sun, 3 Dec 2023 19:29:16 -0500 Subject: [PATCH 4/4] Reverted changes in .gitignore --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 0a1f4d71c149..41c97b62c51e 100644 --- a/.gitignore +++ b/.gitignore @@ -113,6 +113,3 @@ lib/matplotlib/backends/web_backend/node_modules/ lib/matplotlib/backends/web_backend/package-lock.json LICENSE/LICENSE_QHULL - -# My virtual environment # -/venv/