8000 Merge pull request #27211 from CozyFrog/test_hlines · matplotlib/matplotlib@02489d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 02489d4

Browse files
authored
Merge pull request #27211 from CozyFrog/test_hlines
Add test_hlines to test_datetimes.py
2 parents 43929f3 + c81bbaf commit 02489d4

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,43 @@ def test_hist2d(self):
343343
fig, ax = plt.subplots()
344344
ax.hist2d(...)
345345

346-
@pytest.mark.xfail(reason="Test for hlines not written yet")
347346
@mpl.style.context("default")
348347
def test_hlines(self):
349-
fig, ax = plt.subplots()
350-
ax.hlines(...)
348+
mpl.rcParams["date.converter"] = 'concise'
349+
fig, axs = plt.subplots(2, 4, layout='constrained')
350+
dateStrs = ['2023-03-08',
351+
'2023-04-09',
352+
'2023-05-13',
353+
'2023-07-28',
354+
'2023-12-24']
355+
dates = [datetime.datetime(2023, m*2, 10) for m in range(1, 6)]
356+
date_start = [datetime.datetime(2023, 6, d) for d in range(5, 30, 5)]
357+
date_end = [datetime.datetime(2023, 7, d) for d in range(5, 30, 5)]
358+
npDates = [np.datetime64(s) for s in dateStrs]
359+
axs[0, 0].hlines(y=dates,
360+
xmin=[0.1, 0.2, 0.3, 0.4, 0.5],
361+
xmax=[0.5, 0.6, 0.7, 0.8, 0.9])
362+
axs[0, 1].hlines(dates,
363+
xmin=datetime.datetime(2020, 5, 10),
364+
xmax=datetime.datetime(2020, 5, 31))
365+
axs[0, 2].hlines(dates,
366+
xmin=date_start,
367+
xmax=date_end)
368+
axs[0, 3].hlines(dates,
369+
xmin=0.45,
370+
xmax=0.65)
371+
axs[1, 0].hlines(y=npDates,
372+
xmin=[0.5, 0.6, 0.7, 0.8, 0.9],
373+
xmax=[0.1, 0.2, 0.3, 0.4, 0.5])
374+
axs[1, 2].hlines(y=npDates,
375+
xmin=date_start,
376+
xmax=date_end)
377+
axs[1, 1].hlines(npDates,
378+
xmin=datetime.datetime(2020, 5, 10),
379+
xmax=datetime.datetime(2020, 5, 31))
380+
axs[1, 3].hlines(npDates,
381+
xmin=0.45,
382+
xmax=0.65)
351383

352384
@pytest.mark.xfail(reason="Test for imshow not written yet")
353385
@mpl.style.context("default")

0 commit comments

Comments
 (0)
0