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

Skip to content

Commit b98b591

Browse files
LTS42solvents
authored andcommitted
Added violinplot tests.
1 parent 690c770 commit b98b591

16 files changed

+7319
-0
lines changed
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_axes/test_vert_violinplot_baseline.svg

Lines changed: 1374 additions & 0 deletions
Loading
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_axes/test_vert_violinplot_showall.svg

Lines changed: 1514 additions & 0 deletions
Loading

lib/matplotlib/tests/baseline_images/test_axes/test_vert_violinplot_showextrema.svg

Lines changed: 1458 additions & 0 deletions
Loading
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_axes/test_vert_violinplot_showmeans.svg

Lines changed: 1402 additions & 0 deletions
Loading

lib/matplotlib/tests/baseline_images/test_axes/test_vert_violinplot_showmedians.svg

Lines changed: 1402 additions & 0 deletions
Loading

lib/matplotlib/tests/test_axes.py

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,175 @@ def test_boxplot_bad_ci_2():
15641564
fig, ax = plt.subplots()
15651565
assert_raises(ValueError, ax.boxplot, [x, x],
15661566
conf_intervals=[[1, 2], [1]])
1567+
# violin plot data initialization
1568+
ax = plt.axes()
1569+
data = [([ 0.07902449, -0.16769639, 1.1572525 , 0.71400729, -0.17916727,
1570+
-1.15346725, -0.5298936 , 1.16570619, 1.13612837, -0.66830221,
1571+
-0.76738509, 0.85911678, 0.56446469, 0.64772651, -1.97432723,
1572+
-1.11794413, 0.4094635 , 2.52767469, -0.81092698, -0.23422668,
1573+
0.423861 , 0.01702886, -0.58954823, -1.05303546, 0.22632754,
1574+
-1.88620214, 0.06759594, -0.51663253, -0.38821442, -0.5462294 ,
1575+
-0.39967334, -1.2690421 , -0.271953 , 0.19494831, 1.0674446 ,
1576+
0.06632929, 0.9051155 , -0.06507299, -0.58885588, 0.03405925,
1577+
0.60666877, -0.25755542, 1.06387913, -0.50576651, -0.51104135,
1578+
-0.65366091, -1.10801137, 0.55746182, 0.27206281, 0.25658797,
1579+
0.008253 , -0.07254077, -0.77980703, -1.5707303 , -0.74731452,
1580+
-0.38364682, 1.37653142, -0.04123221, -0.84737153, 0.26552353,
1581+
0.80039697, 0.17446856, 0.32860543, 0.79574814, -1.88942134]),
1582+
([ 3.99586977e-01, 1.09626020e+00, 2.64974356e-01,5.49065532e-01,
1583+
-1.86679220e+00, -4.23951661e-01, -3.66858136e-01,7.39441772e-02,
1584+
-1.25772592e+00, -1.14864510e+00, -7.59625813e-01,-2.67830782e-01,
1585+
-2.68205909e-01, -2.64119550e-02, -3.00092210e-01,-1.17080290e-03,
1586+
1.25324397e+00, 1.97518726e-01, 9.74395138e-01, -2.52217468e-01,
1587+
-2.00424239e+00, -2.20525681e+00, 6.32069078e-01, -5.59674009e-02,
1588+
-1.13007054e+00, 8.47680697e-01, -1.41563783e+00, 6.84885681e-02,
1589+
8.06629024e-01, 1.06561293e+00, 1.48755064e-01, 1.06241336e+00,
1590+
-1.53742677e+00, -9.40116707e-01, -2.35342351e-01, 4.07790960e-01,
1591+
9.59066810e-01, 1.83262266e+00, -1.44675794e-01, -1.61663789e+00,
1592+
-3.34055942e-01, -1.65081542e+00, 6.54573563e-01, -4.80998938e-01,
1593+
-4.77104620e-01, 4.35836897e-01, 1.54488583e-01, 1.90264111e+00,
1594+
-1.73584727e+00, 2.84097580e-01, -6.67013428e-01, -5.47647643e-01,
1595+
-1.77584471e-01, -6.54191064e-01, 1.02366976e+00, 1.57777769e+00,
1596+
2.10098337e-01, -5.34631915e-02, 4.28913084e-01, -5.56544884e-02,
1597+
1.64250239e-01, -4.77299164e-01, -8.40402132e-01, -1.58474541e-01]),
1598+
([-0.00975961, -0.9572654 , -0.02331628, -0.88758431, 0.36594918,
1599+
0.58733922, 0.12169127, -0.17451044, -1.48322656, -0.64203124,
1600+
1.01373274, -0.77332978, -1.64093613, 0.07944897, 1.79420792,
1601+
-0.95589844, -2.19618124, 0.99478738, -1.98933911, 0.21046525,
1602+
-2.31831045, 1.11045528, -0.51981581, 0.49740564, -0.40365721,
1603+
-0.30515722, -0.60601737, -1.05976064, 1.43356283, -0.59014164,
1604+
0.58822025, 1.80100922, -1.40905671, 0.74553523, -1.57655404,
1605+
0.29342432, 0.35548625, -0.99138976, -1.37339981, 0.63871936,
1606+
-0.60010678, -0.73597695, -0.12228469, 0.2467333 , 0.03750118,
1607+
-0.45755544, -0.8648646 , 0.13883081, -0.11239293, -0.7661388 ,
1608+
-0.70841112, -0.51668825, 2.2590876 , 0.61731299, -0.33742898,
1609+
1.40708783, -1.43371511, -1.20425544, 0.79551956, -0.38148021,
1610+
-0.05703633, -0.42718744, 1.86441201, -0.36006341, -2.23769144]),
1611+
([ 0.28379466, 0.31202331, 0.54110464, 0.79957469, 0.02825945,
1612+
1.39430266, 0.38945253, 0.25840893, -1.03405387, 0.3951418 ,
1613+
-0.32782812, -0.49764761, 1.67314785, 0.57207158, 0.42868172,
1614+
-0.66405633, 0.49477738, -0.24707622, -0.91179434, -0.88450974,
1615+
1.47387423, 1.27147423, -1.28664994, 0.84428091, 0.19419244,
1616+
-1.27527008, 1.44462176, 1.21255381, 1.74448494, -1.47661372,
1617+
-1.00577117, -0.68746569, -0.85283125, -0.87339905, -0.05053922,
1618+
1.79110014, -0.99663248, 0.52435397, 1.17699107, -1.51437376,
1619+
0.52402067, -0.68885234, 1.84101899, 1.09318846, 0.66686321,
1620+
-1.14796045, 0.54247117, -2.21273401, -0.44526518, 1.08591603,
1621+
-1.86173825, -1.31016714, 0.7782744 , 0.76330906, -0.96452241,
1622+
-1.34983597, -0.90317774, 0.20187156, -2.03515866, 1.35603702,
1623+
1.01390851, 0.29328188, -0.2223719 , -1.29928072, 0.59399753])]
1624+
1625+
# violin plot test starts here
1626+
@image_comparison(baseline_images=['test_vert_violinplot_baseline'])
1627+
def test_vert_violinplot_baseline():
1628+
ax = plt.axes()
1629+
ax.violinplot(data,range(4),showmeans=0,showextrema=0,showmedians=0)
1630+
1631+
@image_comparison(baseline_images=['test_vert_violinplot_showmeans'])
1632+
def test_vert_violinplot_showmeans():
1633+
ax = plt.axes()
1634+
ax.violinplot(data,range(4),showmeans=1,showextrema=0,showmedians=0)
1635+
1636+
@image_comparison(baseline_images=['test_vert_violinplot_showextrema'])
1637+
def test_vert_violinplot_showextrema():
1638+
ax = plt.axes()
1639+
ax.violinplot(data,range(4),showmeans=0,showextrema=1,showmedians=0)
1640+
1641+
@image_comparison(baseline_images=['test_vert_violinplot_showmedians'])
1642+
def test_vert_violinplot_showmedians():
1643+
ax = plt.axes()
1644+
ax.violinplot(data,range(4),showmeans=0,showextrema=0,showmedians=1)
1645+
1646+
@image_comparison(baseline_images=['test_vert_violinplot_showall'])
1647+
def test_vert_violinplot_showall():
1648+
ax = plt.axes()
1649+
ax.violinplot(data,range(4),showmeans=1,showextrema=1,showmedians=1)
1650+
1651+
1652+
@image_comparison(baseline_images=['test_vert_violinplot_customwidths'],
1653+
extensions=['png'],
1654+
savefig_kwarg={'dpi': 40})
1655+
def test_vert_violinplot_customwidths():
1656+
pass
1657+
1658+
1659+
@image_comparison(baseline_images=['test_vert_violinplot_custompoints_10'],
1660+
extensions=['png'],
1661+
savefig_kwarg={'dpi': 40})
1662+
def test_vert_violinplot_custompoints_10():
1663+
pass
1664+
1665+
1666+
@image_comparison(baseline_images=['test_vert_violinplot_custompoints_200'],
1667+
extensions=['png'],
1668+
savefig_kwarg={'dpi': 40})
1669+
def test_vert_violinplot_custompoints_200():
1670+
pass
1671+
1672+
@image_comparison(baseline_images=['test_horiz_violinplot_baseline'],
1673+
extensions=['png'],
1674+
savefig_kwarg={'dpi': 40})
1675+
def test_horiz_violinplot_baseline():
1676+
pass
1677+
1678+
@image_comparison(baseline_images=['test_horiz_violinplot_showmedian'],
1679+
extensions=['png'],
1680+
savefig_kwarg={'dpi': 40})
1681+
def test_horiz_violinplot_showmedian():
1682+
pass
1683+
1684+
@image_comparison(baseline_images=['test_horiz_violinplot_showmean'],
1685+
extensions=['png'],
1686+
savefig_kwarg={'dpi': 40})
1687+
def test_horiz_violinplot_showmean():
1688+
pass
1689+
1690+
1691+
@image_comparison(baseline_images=['test_horiz_violinplot_showextrema'],
1692+
extensions=['png'],
1693+
savefig_kwarg={'dpi': 40})
1694+
def test_horiz_violinplot_showextrema():
1695+
pass
1696+
1697+
1698+
@image_comparison(baseline_images=['test_horiz_violinplot_show_mme'],
1699+
extensions=['png'],
1700+
savefig_kwarg={'dpi': 40})
1701+
def test_horiz_violinplot_show_mme():
1702+
pass
1703+
1704+
1705+
@image_comparison(baseline_images=['test_horiz_violinplot_customwidths'],
1706+
extensions=['png'],
1707+
savefig_kwarg={'dpi': 40})
1708+
def test_horiz_violinplot_customwidths():
1709+
pass
1710+
1711+
1712+
@image_comparison(baseline_images=['test_horiz_violinplot_custompoints_10'],
1713+
extensions=['png'],
1714+
savefig_kwarg={'dpi': 40})
1715+
def test_horiz_violinplot_custompoints_10():
1716+
pass
1717+
1718+
1719+
@image_comparison(baseline_images=['test_horiz_violinplot_custompoints_200'],
1720+
extensions=['png'],
1721+
savefig_kwarg={'dpi': 40})
1722+
def test_horiz_violinplot_custompoints_200():
1723+
pass
1724+
1725+
# test error
1726+
def test_violinplot_bad_positions():
1727+
ax = plt.axes()
1728+
assert_raises(ValueError, ax.violinplot, data, positions=range(5))
1729+
1730+
def test_violinplot_bad_widths():
1731+
ax = plt.axes()
1732+
assert_raises(ValueError, ax.violinplot, data,
1733+
positions=range(4), widths=[1,2,3])
1734+
1735+
# violin plot test ends here
15671736

15681737

15691738
@cleanup

0 commit comments

Comments
 (0)