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

Skip to content

Commit a676dce

Browse files
Shriya KalakataShriya Kalakata
Shriya Kalakata
authored and
Shriya Kalakata
committed
Modified test to check for input with varying lengths of data
1 parent 4e45a67 commit a676dce

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -266,30 +266,31 @@ def test_eventplot(self):
266266

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

269-
x_dates1 = np.array([
270-
datetime.datetime(2020, 6, 30),
271-
datetime.datetime(2020, 7, 22),
272-
datetime.datetime(2020, 8, 3),
273-
datetime.datetime(2020, 9, 14),
274-
], dtype=np.datetime64)
269+
x_dates1 = np.array([datetime.datetime(2020, 6, 30),
270+
datetime.datetime(2020, 7, 22),
271+
datetime.datetime(2020, 8, 3),
272+
datetime.datetime(2020, 9, 14),],
273+
dtype=np.datetime64,
274+
)
275275

276276
ax1.eventplot(x_dates1)
277277

278-
x_dates2 = np.array([
279-
[datetime.datetime(2020, 6, 30), datetime.datetime(2020, 7, 22),
280-
datetime.datetime(2020, 8, 3), datetime.datetime(2020, 9, 14)],
281-
[datetime.datetime(2020, 7, 18), datetime.datetime(2020, 7, 21),
282-
datetime.datetime(2020, 8, 3), datetime.datetime(2020, 10, 14)]
283-
], dtype=np.datetime64)
284-
285-
colors = ['C{}'.format(i) for i in range(2)]
286-
lineoffsets = np.array([1, 6])
287-
linelengths = [5, 2]
288-
289-
ax2.eventplot(x_dates2,
290-
colors=colors,
291-
lineoffsets=lineoffsets,
292-
linelengths=linelengths)
278+
start_date = datetime.datetime(2020, 7, 1)
279+
end_date = datetime.datetime(2020, 10, 15)
280+
date_range = end_date - start_date
281+
282+
dates1 = start_date + np.random.rand(30) * date_range
283+
dates2 = start_date + np.random.rand(10) * date_range
284+
dates3 = start_date + np.random.rand(50) * date_range
285+
286+
colors1 = ['C1', 'C2', 'C3']
287+
lineoffsets1 = np.array([1, 6, 8])
288+
linelengths1 = [5, 2, 3]
289+
290+
ax2.eventplot([dates1, dates2, dates3],
291+
colors=colors1,
292+
lineoffsets=lineoffsets1,
293+
linelengths=linelengths1)
293294

294295
@pytest.mark.xfail(reason="Test for fill not written yet")
295296
@mpl.style.context("default")

0 commit comments

Comments
 (0)