@@ -242,7 +242,13 @@ def test_make_compound_path_stops():
242242 assert np .sum (compound_path .codes == Path .STOP ) == 0
243243
244244
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+
245250def test_xkcd_seed_update ():
251+ # when passing a seed to xkcd, the global rcParam should be updated
246252 with plt .xkcd (seed = 2000 ):
247253 assert rcParams ['path.sketch_seed' ] == 2000
248254
@@ -284,7 +290,9 @@ def test_artist_seed():
284290 ln [0 ].set_sketch_params (3 , 120 , 40 , 2000 )
285291
286292 # 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
288296 ln_2 = ax .plot (x , y_2 , color = 'green' )
289297 ln_2 [0 ].set_sketch_params (3 , 120 , 40 , 19680801 )
290298
@@ -306,8 +314,10 @@ def test_xkcd_seed():
306314 ln = ax .plot (x , y_1 , color = 'black' )
307315 ln [0 ].set_sketch_params (3 , 120 , 40 )
308316
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
311321 with plt .xkcd (3 , 120 , 40 , seed = 420 ):
312322 ln_2 = ax .plot (x , y_2 , color = 'orange' )
313323
@@ -318,6 +328,8 @@ def test_path_seed():
318328 y_1 = 20 * np .sin (x )
319329 y_2 = 20 * np .sin (x )+ 10
320330 fig , ax = plt .subplots ()
331+
332+ # if no seed is passed in set_sketch, rcParam should be used as seed
321333 rcParams ['path.sketch_seed' ] = 645
322334 ln = ax .plot (x , y_1 , color = 'blue' )
323335 ln [0 ].set_sketch_params (3 , 120 , 40 )
0 commit comments