From fc8791df324fff036affb5bc622157d0e2d08a39 Mon Sep 17 00:00:00 2001 From: Junpei Ota Date: Sat, 21 Oct 2023 00:15:03 -0400 Subject: [PATCH 1/3] Added smoke test for Axes.step --- lib/matplotlib/tests/test_datetime.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index f42e0a0d04d8..63c28a828d2a 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -343,11 +343,24 @@ def test_stem(self): fig, ax = plt.subplots() ax.stem(...) - @pytest.mark.xfail(reason="Test for step not written yet") @mpl.style.context("default") def test_step(self): - fig, ax = plt.subplots() - ax.step(...) + mpl.rcParams["date.converter"] = "concise" + limit = 5 + fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1, layout="constrained") + + start_date = datetime.date(2023, 1, 1) + date_x = [start_date + datetime.timedelta(days=i) for i in range(1, limit)] + date_y = [start_date + datetime.timedelta(days=i) for i in range(1, limit)] + x_ranges = np.array(range(1, limit)) + y_ranges = np.array(range(1, limit)) + + ax1.step(x_ranges, date_y, 'g', where='pre', label='pre') + ax2.step(date_x, y_ranges, 'b', where='mid', label='mid') + ax3.step(date_x, date_y, 'r', where='post', label='post') + ax4.step("date", "signal", + data={"date": date_x, "signal": y_ranges}, + where='mid', label='mid') @pytest.mark.xfail(reason="Test for streamplot not written yet") @mpl.style.context("default") From 3dd8da17dfcce2e8240b54940403b61ba014c3a9 Mon Sep 17 00:00:00 2001 From: Junpei Ota Date: Mon, 23 Oct 2023 20:18:12 -0400 Subject: [PATCH 2/3] Fix for underindentation --- 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 63c28a828d2a..598dd731f911 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -359,8 +359,8 @@ def test_step(self): ax2.step(date_x, y_ranges, 'b', where='mid', label='mid') ax3.step(date_x, date_y, 'r', where='post', label='post') ax4.step("date", "signal", - data={"date": date_x, "signal": y_ranges}, - where='mid', label='mid') + data={"date": date_x, "signal": y_ranges}, + where='mid', label='mid') @pytest.mark.xfail(reason="Test for streamplot not written yet") @mpl.style.context("default") From 2982f5ebeefd8dcbf3a2063eaf3db50c0e937292 Mon Sep 17 00:00:00 2001 From: Junpei Ota Date: Tue, 24 Oct 2023 12:27:42 -0400 Subject: [PATCH 3/3] Changed variable names --- lib/matplotlib/tests/test_datetime.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 598dd731f911..6ea29c78f506 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -350,16 +350,16 @@ def test_step(self): fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1, layout="constrained") start_date = datetime.date(2023, 1, 1) - date_x = [start_date + datetime.timedelta(days=i) for i in range(1, limit)] - date_y = [start_date + datetime.timedelta(days=i) for i in range(1, limit)] + x_date = [start_date + datetime.timedelta(days=i) for i in range(1, limit)] + y_date = [start_date + datetime.timedelta(days=i) for i in range(1, limit)] x_ranges = np.array(range(1, limit)) y_ranges = np.array(range(1, limit)) - ax1.step(x_ranges, date_y, 'g', where='pre', label='pre') - ax2.step(date_x, y_ranges, 'b', where='mid', label='mid') - ax3.step(date_x, date_y, 'r', where='post', label='post') + ax1.step(x_ranges, y_date, 'g', where='pre', label='pre') + ax2.step(x_date, y_ranges, 'b', where='mid', label='mid') + ax3.step(x_date, y_date, 'r', where='post', label='post') ax4.step("date", "signal", - data={"date": date_x, "signal": y_ranges}, + data={"date": x_date, "signal": y_ranges}, where='mid', label='mid') @pytest.mark.xfail(reason="Test for streamplot not written yet")