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

Skip to content

Commit 980e551

Browse files
committed
unittest for all problem keyword arguments to ax.eventplot
1 parent 2ecb007 commit 980e551

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import matplotlib.markers as mmarkers
2121
from numpy.testing import assert_array_equal
2222
import warnings
23+
from matplotlib.cbook import IgnoredKeywordWarning
2324

2425

2526
@image_comparison(baseline_images=['formatter_ticker_001',
@@ -2317,6 +2318,37 @@ def test_eventplot_defaults():
23172318
colls = axobj.eventplot(data)
23182319

23192320

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+
23202352
@cleanup
23212353
def test_empty_eventplot():
23222354
fig, ax = plt.subplots(1, 1)

0 commit comments

Comments
 (0)