From 47015e4e196233caefc7abe7c375ca7aa48c965c Mon Sep 17 00:00:00 2001 From: ifEricReturnTrue <86877855+ifEricReturnTrue@users.noreply.github.com> Date: Sat, 2 Dec 2023 16:36:30 -0500 Subject: [PATCH 1/9] Completed Axes.stairs test_datetime.py Tested error-free --- lib/matplotlib/tests/test_datetime.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 316be793e47c..5ed8d5586180 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -508,11 +508,23 @@ def test_stackplot(self): fig, ax = plt.subplots(layout='constrained') ax.stackplot(dates, stacked_nums) - @pytest.mark.xfail(reason="Test for stairs not written yet") @mpl.style.context("default") def test_stairs(self): - fig, ax = plt.subplots() - ax.stairs(...) + mpl.rcParams["date.converter"] = 'concise' + + start_date = datetime.datetime(2023, 12, 1) + time_delta = datetime.timedelta(days=1) + + bin_edges = [start_date + i * time_delta for i in range(31)] + np.random.seed(123456) + values1 = np.random.randint(1, 100, 30) + values2 = np.random.randint(1, 100, 30) + values3 = np.random.randint(1, 100, 30) + + fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) + ax1.stairs(values1, edges=bin_edges) + ax2.stairs(values2, edges=bin_edges) + ax3.stairs(values3, edges=bin_edges) @pytest.mark.xfail(reason="Test for stem not written yet") @mpl.style.context("default") From 4ccf16b5f99a77f291ea289b374a725fb0f32f0c Mon Sep 17 00:00:00 2001 From: ifEricReturnTrue <86877855+ifEricReturnTrue@users.noreply.github.com> Date: Sat, 2 Dec 2023 16:46:15 -0500 Subject: [PATCH 2/9] Update test_datetime.py --- lib/matplotlib/tests/test_datetime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 5ed8d5586180..83a9d25b8ba9 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -516,7 +516,7 @@ def test_stairs(self): time_delta = datetime.timedelta(days=1) bin_edges = [start_date + i * time_delta for i in range(31)] - np.random.seed(123456) + np.random.seed(1234567) values1 = np.random.randint(1, 100, 30) values2 = np.random.randint(1, 100, 30) values3 = np.random.randint(1, 100, 30) From e549c81d9bc7f24cc922124d5d0ea3463c5daa4b Mon Sep 17 00:00:00 2001 From: ifEricReturnTrue <86877855+ifEricReturnTrue@users.noreply.github.com> Date: Sat, 2 Dec 2023 16:54:49 -0500 Subject: [PATCH 3/9] Reverting unexpected changes in test_datetime.py in the previous commit --- lib/matplotlib/tests/test_datetime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 83a9d25b8ba9..5ed8d5586180 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -516,7 +516,7 @@ def test_stairs(self): time_delta = datetime.timedelta(days=1) bin_edges = [start_date + i * time_delta for i in range(31)] - np.random.seed(1234567) + np.random.seed(123456) values1 = np.random.randint(1, 100, 30) values2 = np.random.randint(1, 100, 30) values3 = np.random.randint(1, 100, 30) From 42b4d19a6391fbde17115fa735e86d21f8b5d3aa Mon Sep 17 00:00:00 2001 From: ifEricReturnTrue <86877855+ifEricReturnTrue@users.noreply.github.com> Date: Mon, 4 Dec 2023 21:59:34 -0500 Subject: [PATCH 4/9] Update test_stairs as requested --- lib/matplotlib/tests/test_datetime.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 5ed8d5586180..1a2da8415e80 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -516,14 +516,17 @@ def test_stairs(self): time_delta = datetime.timedelta(days=1) bin_edges = [start_date + i * time_delta for i in range(31)] + edge_int = [0 + i * 1 for i in range(31)] np.random.seed(123456) values1 = np.random.randint(1, 100, 30) - values2 = np.random.randint(1, 100, 30) - values3 = np.random.randint(1, 100, 30) + random_day = np.random.randint(1, 10000, 30) + values2 = [start_date + datetime.timedelta(days=int(random_day[i])) for i in range(30)] + random_day = np.random.randint(-10000, 10000, 30) + values3 = [start_date + datetime.timedelta(days=int(random_day[i])) for i in range(30)] fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) ax1.stairs(values1, edges=bin_edges) - ax2.stairs(values2, edges=bin_edges) + ax2.stairs(values2, edges=edge_int) ax3.stairs(values3, edges=bin_edges) @pytest.mark.xfail(reason="Test for stem not written yet") From 0d1798b23f5497b3421d15d2cc630732f26631e5 Mon Sep 17 00:00:00 2001 From: ifEricReturnTrue <86877855+ifEricReturnTrue@users.noreply.github.com> Date: Mon, 4 Dec 2023 22:05:13 -0500 Subject: [PATCH 5/9] Fixing linting errors --- lib/matplotlib/tests/test_datetime.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 1a2da8415e80..d18ee53167cd 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -520,9 +520,11 @@ def test_stairs(self): np.random.seed(123456) values1 = np.random.randint(1, 100, 30) random_day = np.random.randint(1, 10000, 30) - values2 = [start_date + datetime.timedelta(days=int(random_day[i])) for i in range(30)] + values2 = [start_date + + datetime.timedelta(days=int(random_day[i])) for i in range(30)] random_day = np.random.randint(-10000, 10000, 30) - values3 = [start_date + datetime.timedelta(days=int(random_day[i])) for i in range(30)] + values3 = [start_date + + datetime.timedelta(days=int(random_day[i])) for i in range(30)] fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) ax1.stairs(values1, edges=bin_edges) From ff7e6aecaced83b517a22cf262722c526400e116 Mon Sep 17 00:00:00 2001 From: ifEricReturnTrue <86877855+ifEricReturnTrue@users.noreply.github.com> Date: Sat, 9 Dec 2023 16:13:06 -0500 Subject: [PATCH 6/9] Adding Baseline data for the test --- lib/matplotlib/tests/test_datetime.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index d18ee53167cd..047c9b2360f3 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -514,6 +514,7 @@ def test_stairs(self): start_date = datetime.datetime(2023, 12, 1) time_delta = datetime.timedelta(days=1) + baseline_date = datetime.datetime(1980, 1, 1) bin_edges = [start_date + i * time_delta for i in range(31)] edge_int = [0 + i * 1 for i in range(31)] @@ -528,8 +529,8 @@ def test_stairs(self): fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) ax1.stairs(values1, edges=bin_edges) - ax2.stairs(values2, edges=edge_int) - ax3.stairs(values3, edges=bin_edges) + ax2.stairs(values2, edges=edge_int, baseline = baseline_date) + ax3.stairs(values3, edges=bin_edges, baseline = baseline_date) @pytest.mark.xfail(reason="Test for stem not written yet") @mpl.style.context("default") From 4a8cd7d7715d948a41ec1cf80cc8f34a7be2e90e Mon Sep 17 00:00:00 2001 From: ifEricReturnTrue <86877855+ifEricReturnTrue@users.noreply.github.com> Date: Sat, 9 Dec 2023 16:16:14 -0500 Subject: [PATCH 7/9] Fixing linting error --- 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 047c9b2360f3..c89aa0dc4112 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -529,8 +529,8 @@ def test_stairs(self): fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) ax1.stairs(values1, edges=bin_edges) - ax2.stairs(values2, edges=edge_int, baseline = baseline_date) - ax3.stairs(values3, edges=bin_edges, baseline = baseline_date) + ax2.stairs(values2, edges=edge_int, baseline=baseline_date) + ax3.stairs(values3, edges=bin_edges, baseline=baseline_date) @pytest.mark.xfail(reason="Test for stem not written yet") @mpl.style.context("default") From 8c355d233593496e7707873375cd5d1c7be88c81 Mon Sep 17 00:00:00 2001 From: ifEricReturnTrue <86877855+ifEricReturnTrue@users.noreply.github.com> Date: Tue, 12 Dec 2023 15:04:36 -0500 Subject: [PATCH 8/9] Update stairs test as suggested Co-authored-by: Elliott Sales de Andrade --- lib/matplotlib/tests/test_datetime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index c89aa0dc4112..e6c62389aa74 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -517,7 +517,7 @@ def test_stairs(self): baseline_date = datetime.datetime(1980, 1, 1) bin_edges = [start_date + i * time_delta for i in range(31)] - edge_int = [0 + i * 1 for i in range(31)] + edge_int = np.arange(31) np.random.seed(123456) values1 = np.random.randint(1, 100, 30) random_day = np.random.randint(1, 10000, 30) From 3ed61d0ab6f1ba4f529653a621f7f2333944393d Mon Sep 17 00:00:00 2001 From: ifEricReturnTrue <86877855+ifEricReturnTrue@users.noreply.github.com> Date: Tue, 12 Dec 2023 15:04:47 -0500 Subject: [PATCH 9/9] Update stairs test as suggested Co-authored-by: Elliott Sales de Andrade --- lib/matplotlib/tests/test_datetime.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index e6c62389aa74..6700369cb2c3 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -520,12 +520,10 @@ def test_stairs(self): edge_int = np.arange(31) np.random.seed(123456) values1 = np.random.randint(1, 100, 30) - random_day = np.random.randint(1, 10000, 30) - values2 = [start_date + - datetime.timedelta(days=int(random_day[i])) for i in range(30)] - random_day = np.random.randint(-10000, 10000, 30) - values3 = [start_date + - datetime.timedelta(days=int(random_day[i])) for i in range(30)] + values2 = [start_date + datetime.timedelta(days=int(i)) + for i in np.random.randint(1, 10000, 30)] + values3 = [start_date + datetime.timedelta(days=int(i)) + for i in np.random.randint(-10000, 10000, 30)] fig, (ax1, ax2, ax3) = plt.subplots(3, 1, constrained_layout=True) ax1.stairs(values1, edges=bin_edges)