|
20 | 20 | import matplotlib.markers as mmarkers
|
21 | 21 | from numpy.testing import assert_array_equal
|
22 | 22 | import warnings
|
| 23 | +from matplotlib.cbook import IgnoredKeywordWarning |
23 | 24 |
|
24 | 25 |
|
25 | 26 | @image_comparison(baseline_images=['formatter_ticker_001',
|
@@ -2317,6 +2318,37 @@ def test_eventplot_defaults():
|
2317 | 2318 | colls = axobj.eventplot(data)
|
2318 | 2319 |
|
2319 | 2320 |
|
| 2321 | +@image_comparison(baseline_images=['test_eventplot_problem_kwargs'], extensions=['png'], remove_text=True) |
| 2322 | +def test_eventplot_problem_kwargs(): |
| 2323 | + ''' |
| 2324 | + test that 'singular' versions of LineCollection props raise an |
| 2325 | + IgnoredKeywordWarning rather than overriding the 'plural' versions (e.g. |
| 2326 | + to prevent 'color' from overriding 'colors', see issue #4297) |
| 2327 | + ''' |
| 2328 | + np.random.seed(0) |
| 2329 | + |
| 2330 | + data1 = np.random.random([20]).tolist() |
| 2331 | + data2 = np.random.random([10]).tolist() |
| 2332 | + data = [data1, data2] |
| 2333 | + |
| 2334 | + fig = plt.figure() |
| 2335 | + axobj = fig.add_subplot(111) |
| 2336 | + |
| 2337 | + with warnings.catch_warnings(record=True) as w: |
| 2338 | + colls = axobj.eventplot(data, |
| 2339 | + colors=['r', 'b'], |
| 2340 | + color=['c', 'm'], |
| 2341 | + linewidths=[2, 1], |
| 2342 | + linewidth=[1, 2], |
| 2343 | + linestyles=['solid', 'dashed'], |
| 2344 | + linestyle=['dashdot', 'dotted']) |
| 2345 | + |
| 2346 | + # check that three IgnoredKeywordWarnings were raised |
| 2347 | + assert_equal(len(w), 3) |
| 2348 | + assert_true(all(issubclass(wi.category, IgnoredKeywordWarning) |
| 2349 | + for wi in w)) |
| 2350 | + |
| 2351 | + |
2320 | 2352 | @cleanup
|
2321 | 2353 | def test_empty_eventplot():
|
2322 | 2354 | fig, ax = plt.subplots(1, 1)
|
|
0 commit comments