Skip to content

Commit 1a6a11a

Browse files
committed
Add datetime test for ax.violin
1 parent dfc888c commit 1a6a11a

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,11 +810,31 @@ def test_triplot(self):
810810
fig, ax = plt.subplots()
811811
ax.triplot(...)
812812

813-
@pytest.mark.xfail(reason="Test for violin not written yet")
813+
@pytest.mark.parametrize(("orientation"), ["vertical", "horizontal"])
814814
@mpl.style.context("default")
815-
def test_violin(self):
815+
def test_violin(self, orientation):
816816
fig, ax = plt.subplots()
817-
ax.violin(...)
817+
datetimes = [
818+
datetime.datetime(2023, 2, 10),
819+
datetime.datetime(2023, 5, 18),
820+
datetime.datetime(2023, 6, 6)
821+
]
822+
ax.violin(
823+
[
824+
{
825+
'coords': datetimes,
826+
'vals': [0.1, 0.5, 0.2],
827+
'mean': datetimes[1],
828+
'median': datetimes[1],
829+
'min': datetimes[0],
830+
'max': datetimes[-1],
831+
'quantiles': datetimes
832+
}
833+
],
834+
orientation=orientation,
835+
# TODO: allow positions to be datetimes?
836+
# positions=[datetime.datetime(2020, 1, 1)]
837+
)
818838

819839
@pytest.mark.xfail(reason="Test for violinplot not written yet")
820840
@mpl.style.context("default")

0 commit comments

Comments
 (0)