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 6157b1f7ff12bfce66f18cc890d8cbf437c85c12 Mon Sep 17 00:00:00 2001 From: Nidaa Rabah <136858218+nidaa-7@users.noreply.github.com> Date: Wed, 29 Nov 2023 23:25:25 -0500 Subject: [PATCH 3/4] reverted .gitignore changes I had added my virtual environment to gitignore and pushed it. Reverted back before pull request --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index ee9652442b7a..99e7a628cffd 100644 --- a/.gitignore +++ b/.gitignore @@ -114,6 +114,3 @@ lib/matplotlib/backends/web_backend/node_modules/ lib/matplotlib/backends/web_backend/package-lock.json LICENSE/LICENSE_QHULL - -# My virtual environment # -/venv/ From b553dab8bbb8f15ee4bfbb7f92665cd1049466f5 Mon Sep 17 00:00:00 2001 From: Nidaa Rabah <136858218+nidaa-7@users.noreply.github.com> Date: Thu, 30 Nov 2023 09:28:38 +0000 Subject: [PATCH 4/4] added seed --- lib/matplotlib/tests/test_datetime.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index d998800e2096..7b94f3482bfa 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -271,6 +271,8 @@ def test_fill(self): mpl.rcParams["date.converter"] = "concise" 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] for _ in range(1, 5):