From d96219a1ffdf2dd776b6fb898d1b2391d01f79da Mon Sep 17 00:00:00 2001 From: QuadroTec <19280099+QuadroTec@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:31:33 +1100 Subject: [PATCH 1/3] add test_stackplot in test_datetime.py --- lib/matplotlib/tests/test_datetime.py | 35 ++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index ef83b837348d..f17700dc2395 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -318,11 +318,40 @@ def test_spy(self): fig, ax = plt.subplots() ax.spy(...) - @pytest.mark.xfail(reason="Test for stackplot not written yet") @mpl.style.context("default") def test_stackplot(self): - fig, ax = plt.subplots() - ax.stackplot(...) + mpl.rcParams["date.converter"] = 'concise' + N = 10 + fig, (ax1, ax2) = plt.subplots(2, 1, constrained_layout=True) + + stacked_nums = np.array([range(1, N)] * 4) + + dates_days = np.array( + [datetime.datetime(2023, 1, i) for i in range(1, N)] + ) + dates_years = np.array( + [datetime.datetime(1970 + i, 1, 1) for i in range(1, N)] + ) + + timedelta_days = np.array( + [i * datetime.timedelta(days=1) for i in range(1, N)] + ) + timedelta_hours = np.array( + [i * datetime.timedelta(hours=24) for i in range(1, N)] + ) + timedelta_seconds = np.array( + [i * datetime.timedelta(seconds=86400) for i in range(1, N)] + ) + + ax1.stackplot(dates_years, stacked_nums) + + ax2.stackplot( + dates_days, dates_days, timedelta_days, timedelta_hours, timedelta_seconds + ) + ax2.set_ylim( + datetime.datetime(2022, 12, 31), + datetime.datetime(2023, 2, 8) + ) @pytest.mark.xfail(reason="Test for stairs not written yet") @mpl.style.context("default") From 3cf5376844bf252e7c754a87c13a7d747bde6d2b Mon Sep 17 00:00:00 2001 From: QuadroTec <19280099+QuadroTec@users.noreply.github.com> Date: Tue, 17 Oct 2023 18:12:48 +1100 Subject: [PATCH 2/3] Remove stackplot test with datetime y-axis --- lib/matplotlib/tests/test_datetime.py | 30 +++------------------------ 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index f17700dc2395..b3f0441f393f 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -322,36 +322,12 @@ def test_spy(self): def test_stackplot(self): mpl.rcParams["date.converter"] = 'concise' N = 10 - fig, (ax1, ax2) = plt.subplots(2, 1, constrained_layout=True) + fig, ax = plt.subplots(constrained_layout=True) stacked_nums = np.array([range(1, N)] * 4) + dates = np.array([datetime.datetime(2020 + i, 1, 1) for i in range(N - 1)]) - dates_days = np.array( - [datetime.datetime(2023, 1, i) for i in range(1, N)] - ) - dates_years = np.array( - [datetime.datetime(1970 + i, 1, 1) for i in range(1, N)] - ) - - timedelta_days = np.array( - [i * datetime.timedelta(days=1) for i in range(1, N)] - ) - timedelta_hours = np.array( - [i * datetime.timedelta(hours=24) for i in range(1, N)] - ) - timedelta_seconds = np.array( - [i * datetime.timedelta(seconds=86400) for i in range(1, N)] - ) - - ax1.stackplot(dates_years, stacked_nums) - - ax2.stackplot( - dates_days, dates_days, timedelta_days, timedelta_hours, timedelta_seconds - ) - ax2.set_ylim( - datetime.datetime(2022, 12, 31), - datetime.datetime(2023, 2, 8) - ) + ax.stackplot(dates, stacked_nums) @pytest.mark.xfail(reason="Test for stairs not written yet") @mpl.style.context("default") From d21d836ece7fdc4943cd87a746f0e137c42d302c Mon Sep 17 00:00:00 2001 From: QuadroTec <19280099+QuadroTec@users.noreply.github.com> Date: Wed, 18 Oct 2023 13:40:47 +1100 Subject: [PATCH 3/3] Refactor test_stackplot --- lib/matplotlib/tests/test_datetime.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index b3f0441f393f..b21ff1bb7202 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -322,11 +322,10 @@ def test_spy(self): def test_stackplot(self): mpl.rcParams["date.converter"] = 'concise' N = 10 - fig, ax = plt.subplots(constrained_layout=True) - - stacked_nums = np.array([range(1, N)] * 4) + stacked_nums = np.tile(np.arange(1, N), (4, 1)) dates = np.array([datetime.datetime(2020 + i, 1, 1) for i in range(N - 1)]) + fig, ax = plt.subplots(layout='constrained') ax.stackplot(dates, stacked_nums) @pytest.mark.xfail(reason="Test for stairs not written yet") pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy