@@ -242,7 +242,13 @@ def test_make_compound_path_stops():
242
242
assert np .sum (compound_path .codes == Path .STOP ) == 0
243
243
244
244
245
+ def test_path_sketch_seed ():
246
+ # the default value of path.sketch_seed should be 0
247
+ assert rcParams ['path.sketch_seed' ] == 0
248
+
249
+
245
250
def test_xkcd_seed_update ():
251
+ # when passing a seed to xkcd, the global rcParam should be updated
246
252
with plt .xkcd (seed = 2000 ):
247
253
assert rcParams ['path.sketch_seed' ] == 2000
248
254
@@ -284,7 +290,9 @@ def test_artist_seed():
284
290
ln [0 ].set_sketch_params (3 , 120 , 40 , 2000 )
285
291
286
292
# set_sketch_params seed should override seed set by rcParam
287
- rcParams ['path.sketch_seed' ] = 0
293
+ # when seed is passed in set_sketch, it should be used
294
+ # else rcParam should be used as seed
295
+ rcParams ['path.sketch_seed' ] = 59856
288
296
ln_2 = ax .plot (x , y_2 , color = 'green' )
289
297
ln_2 [0 ].set_sketch_params (3 , 120 , 40 , 19680801 )
290
298
@@ -306,8 +314,10 @@ def test_xkcd_seed():
306
314
ln = ax .plot (x , y_1 , color = 'black' )
307
315
ln [0 ].set_sketch_params (3 , 120 , 40 )
308
316
309
- # xkcd should override rcParam seed.
310
- rcParams ['path.sketch_seed' ] = 0
317
+ # xkcd should override rcParam seed
318
+ # when seed is passed in xkcd, it should be used,else rcParam should be used as seed
319
+ # passing seed to xkcd should also update global rcParam
320
+ rcParams ['path.sketch_seed' ] = 8448
311
321
with plt .xkcd (3 , 120 , 40 , seed = 420 ):
312
322
ln_2 = ax .plot (x , y_2 , color = 'orange' )
313
323
@@ -318,6 +328,8 @@ def test_path_seed():
318
328
y_1 = 20 * np .sin (x )
319
329
y_2 = 20 * np .sin (x )+ 10
320
330
fig , ax = plt .subplots ()
331
+
332
+ # if no seed is passed in set_sketch, rcParam should be used as seed
321
333
rcParams ['path.sketch_seed' ] = 645
322
334
ln = ax .plot (x , y_1 , color = 'blue' )
323
335
ln [0 ].set_sketch_params (3 , 120 , 40 )
0 commit comments