Skip to content

Added Axes.stairs test in test_datetime.py #27424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 13, 2023
22 changes: 19 additions & 3 deletions lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,27 @@ 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)
baseline_date = datetime.datetime(1980, 1, 1)

bin_edges = [start_date + i * time_delta for i in range(31)]
edge_int = np.arange(31)
np.random.seed(123456)
values1 = np.random.randint(1, 100, 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)
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")
Expand Down
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