|
3 | 3 |
|
4 | 4 | import six |
5 | 5 | from six.moves import xrange |
6 | | - |
| 6 | +from itertools import chain |
7 | 7 | import io |
8 | 8 |
|
9 | 9 | from nose.tools import assert_equal, assert_raises, assert_false, assert_true |
|
13 | 13 | import numpy as np |
14 | 14 | from numpy import ma |
15 | 15 | from numpy import arange |
| 16 | +from cycler import cycler |
16 | 17 |
|
17 | 18 | import matplotlib |
18 | 19 | from matplotlib.testing.decorators import image_comparison, cleanup |
@@ -4093,6 +4094,44 @@ def test_violin_point_mass(): |
4093 | 4094 | plt.violinplot(np.array([0, 0])) |
4094 | 4095 |
|
4095 | 4096 |
|
| 4097 | +def _eb_succes_helper(ax, x, y, xerr=None, yerr=None): |
| 4098 | + eb = ax.errorbar(x, y, xerr=xerr, yerr=yerr) |
| 4099 | + eb.remove() |
| 4100 | + |
| 4101 | + |
| 4102 | +@cleanup |
| 4103 | +def test_errorbar_inputs_shotgun(): |
| 4104 | + base_xy = cycler('x', [np.arange(5)]) + cycler('y', [np.ones((5, ))]) |
| 4105 | + err_cycler = cycler('err', [1, |
| 4106 | + [1, 1, 1, 1, 1], |
| 4107 | + [[1, 1, 1, 1, 1], |
| 4108 | + [1, 1, 1, 1, 1]], |
| 4109 | + [[1]] * 5, |
| 4110 | + np.ones(5), |
| 4111 | + np.ones((2, 5)), |
| 4112 | + np.ones((5, 1)), |
| 4113 | + None |
| 4114 | + ]) |
| 4115 | + xerr_cy = cycler('xerr', err_cycler) |
| 4116 | + yerr_cy = cycler('yerr', err_cycler) |
| 4117 | + |
| 4118 | + empty = ((cycler('x', [[]]) + cycler('y', [[]])) * |
| 4119 | + cycler('xerr', [[], None]) * cycler('yerr', [[], None])) |
| 4120 | + xerr_only = base_xy * xerr_cy |
| 4121 | + yerr_only = base_xy * yerr_cy |
| 4122 | + both_err = base_xy * yerr_cy * xerr_cy |
| 4123 | + |
| 4124 | + test_cyclers = xerr_only, yerr_only, both_err, empty |
| 4125 | + |
| 4126 | + ax = plt.gca() |
| 4127 | + # should do this as a generative test, but @cleanup seems to break that |
| 4128 | + # for p in chain(*test_cyclers): |
| 4129 | + # yield (_eb_succes_helper, ax) + tuple(p.get(k, None) for |
| 4130 | + # k in ['x', 'y', 'xerr', 'yerr']) |
| 4131 | + for p in chain(*test_cyclers): |
| 4132 | + _eb_succes_helper(ax, **p) |
| 4133 | + |
| 4134 | + |
4096 | 4135 | @cleanup |
4097 | 4136 | def test_remove_shared_axes(): |
4098 | 4137 |
|
@@ -4137,6 +4176,9 @@ def _helper_y(ax): |
4137 | 4176 | ax.set_xlim(0, 5) |
4138 | 4177 | assert assert_array_equal(ax_lst[0][1].get_xlim(), orig_xlim) |
4139 | 4178 |
|
| 4179 | + |
| 4180 | + |
| 4181 | + |
4140 | 4182 | if __name__ == '__main__': |
4141 | 4183 | import nose |
4142 | 4184 | import sys |
|
0 commit comments