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

Skip to content

Commit 6e629b5

Browse files
committed
Add unit test to ensure that rendering complexity exceeded exception is properly propagated to Python.
svn path=/trunk/matplotlib/; revision=8459
1 parent fb3e697 commit 6e629b5

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

lib/matplotlib/tests/test_simplification.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
from pylab import *
77
import numpy as np
88
from matplotlib import patches, path, transforms
9+
10+
from nose.tools import raises
11+
import cStringIO
12+
913
nan = np.nan
1014
Path = path.Path
1115

@@ -165,6 +169,24 @@ def test_start_with_moveto():
165169
assert len(segs) == 1
166170
assert segs[0][1] == Path.MOVETO
167171

172+
@raises(OverflowError)
173+
def test_throw_rendering_complexity_exceeded():
174+
rcParams['path.simplify'] = False
175+
176+
xx = np.arange(200000)
177+
yy = np.random.rand(200000)
178+
yy[1000] = np.nan
179+
fig = plt.figure()
180+
ax = fig.add_subplot(111)
181+
ax.plot(xx, yy)
182+
try:
183+
fig.savefig(cStringIO.StringIO())
184+
except e:
185+
raise e
186+
else:
187+
rcParams['path.simplify'] = True
188+
189+
168190
if __name__=='__main__':
169191
import nose
170192
nose.runmodule(argv=['-s','--with-doctest'], exit=False)

0 commit comments

Comments
 (0)