Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd2dc510

Browse files
committed
Added tests
1 parent4b652c3 commitd2dc510

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

‎lib/matplotlib/tests/test_artist.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,3 +562,8 @@ def draw(self, renderer, extra):
562562

563563
assert'aardvark'==art.draw(renderer,'aardvark')
564564
assert'aardvark'==art.draw(renderer,extra='aardvark')
565+
566+
567+
deftest_artist_seed_update():
568+
martist.Artist().set_sketch_params(seed=2345)
569+
assertmpl.rcParams['path.sketch_seed']==2345

‎lib/matplotlib/tests/test_path.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,18 @@ def test_make_compound_path_stops():
243243
assertnp.sum(compound_path.codes==Path.STOP)==0
244244

245245

246+
deftest_xkcd_seed_update():
247+
withplt.xkcd(seed=2000):
248+
assertrcParams['path.sketch_seed']==2000
249+
250+
246251
@image_comparison(['xkcd.png'],remove_text=True)
247252
deftest_xkcd():
248253
np.random.seed(0)
249254

250255
x=np.linspace(0,2*np.pi,100)
251256
y=np.sin(x)
252-
# we should be able to update seed through xkcd or Artist().set_sketch_params
253-
rcParams['path.sketch_seed']=19680801
254-
withplt.xkcd(seed=0):
257+
withplt.xkcd():
255258
fig,ax=plt.subplots()
256259
ax.plot(x,y)
257260

@@ -264,16 +267,33 @@ def test_xkcd_marker():
264267
y1=x
265268
y2=5-x
266269
y3=2.5*np.ones(8)
267-
# we should be able to update seed through xkcd or Artist().set_sketch_params
268-
rcParams['path.sketch_seed']=19680801
269270
withplt.xkcd():
270-
artist.Artist().set_sketch_params(seed=0)
271271
fig,ax=plt.subplots()
272272
ax.plot(x,y1,'+',ms=10)
273273
ax.plot(x,y2,'o',ms=10)
274274
ax.plot(x,y3,'^',ms=10)
275275

276276

277+
@image_comparison(['xkcd_artist.png'],remove_text=True)
278+
deftest_xkcd_artist():
279+
withplt.xkcd():
280+
rcParams['path.sketch']= (2,120,40)
281+
artist.Artist().set_sketch_params(seed=19680801)
282+
pat,txt=plt.pie([10,20,30,40],wedgeprops={'edgecolor':'black'})
283+
plt.legend(pat, ['first','second','third','fourth'],loc='best')
284+
plt.plot()
285+
286+
287+
@image_comparison(['xkcd_seed.png'],remove_text=True)
288+
deftest_xkcd_seed():
289+
withplt.xkcd():
290+
rcParams['path.sketch']= (2,120,40)
291+
rcParams['path.sketch_seed']=2000
292+
pat,txt=plt.pie([10,20,30,40],wedgeprops={'edgecolor':'black'})
293+
plt.legend(pat, ['first','second','third','fourth'],loc='best')
294+
plt.plot()
295+
296+
277297
@image_comparison(['marker_paths.pdf'],remove_text=True)
278298
deftest_marker_paths_pdf():
279299
N=7

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp