Skip to content

Commit 3fa749b

Browse files
committed
Add datetime test for ax.violin
1 parent 0a44bcb commit 3fa749b

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,11 +810,32 @@ 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: It should be possible for positions to be datetimes too
836+
# https://github.com/matplotlib/matplotlib/issues/30417
837+
# positions=[datetime.datetime(2020, 1, 1)]
838+
)
818839

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

0 commit comments

Comments
 (0)