Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc8791d

Browse files
committed
Added smoke test for Axes.step
1 parent b617bf5 commit fc8791d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,24 @@ def test_stem(self):
343343
fig, ax = plt.subplots()
344344
ax.stem(...)
345345

346-
@pytest.mark.xfail(reason="Test for step not written yet")
347346
@mpl.style.context("default")
348347
def test_step(self):
349-
fig, ax = plt.subplots()
350-
ax.step(...)
348+
mpl.rcParams["date.converter"] = "concise"
349+
limit = 5
350+
fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1, layout="constrained")
351+
352+
start_date = datetime.date(2023, 1, 1)
353+
date_x = [start_date + datetime.timedelta(days=i) for i in range(1, limit)]
354+
date_y = [start_date + datetime.timedelta(days=i) for i in range(1, limit)]
355+
x_ranges = np.array(range(1, limit))
356+
y_ranges = np.array(range(1, limit))
357+
358+
ax1.step(x_ranges, date_y, 'g', where='pre', label='pre')
359+
ax2.step(date_x, y_ranges, 'b', where='mid', label='mid')
360+
ax3.step(date_x, date_y, 'r', where='post', label='post')
361+
ax4.step("date", "signal",
362+
data={"date": date_x, "signal": y_ranges},
363+
where='mid', label='mid')
351364

352365
@pytest.mark.xfail(reason="Test for streamplot not written yet")
353366
@mpl.style.context("default")

0 commit comments

Comments
 (0)