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

Skip to content

Add test_boxplot to test_datetime.py #27502

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,32 @@ def test_barh(self):
ax2.set_ylabel('Order of Birth Dates')
ax2.barh(np.arange(4), birth_date-year_start, left=year_start)

@pytest.mark.xfail(reason="Test for boxplot not written yet")
@mpl.style.context("default")
def test_boxplot(self):
fig, ax = plt.subplots()
ax.boxplot(...)
mpl.rcParams["date.converter"] = "concise"

fig, (ax1, ax2) = plt.subplots(2, 1, layout="constrained")

dates1 = [
datetime(2023, 1, 1),
datetime(2023, 1, 10),
datetime(2023, 1, 15),
datetime(2023, 1, 20)
]

time_diffs = [(date - min(dates1)).total_seconds() for date in dates1]

ax1.boxplot(time_diffs)

np.random.seed(19680801)

dates2 = [datetime(2023, 1, 1) +
datetime.timedelta(days=np.random.randint(1, 365))
for _ in range(100)]

timestamps = [(date - datetime(1970, 1, 1)).total_seconds() for date in dates2]

ax2.boxplot(timestamps)

@pytest.mark.xfail(reason="Test for broken_barh not written yet")
@mpl.style.context("default")
Expand Down