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

Skip to content
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