@@ -53,13 +53,9 @@ def test_resampled():
5353 colorlist [:, 1 ] = 0.2
5454 colorlist [:, 2 ] = np .linspace (1 , 0 , n )
5555 colorlist [:, 3 ] = 0.7
56- lsc = mcolors .LinearSegmentedColormap .from_list ('lsc' , colorlist )
57- lc = mcolors .ListedColormap (colorlist )
58- # Set some bad values for testing too
59- for cmap in [lsc , lc ]:
60- cmap .set_under ('r' )
61- cmap .set_over ('g' )
62- cmap .set_bad ('b' )
56+ lsc = mcolors .LinearSegmentedColormap .from_list (
57+ 'lsc' , colorlist , under = 'red' , over = 'green' , bad = 'blue' )
58+ lc = mcolors .ListedColormap (colorlist , under = 'red' , over = 'green' , bad = 'blue' )
6359 lsc3 = lsc .resampled (3 )
6460 lc3 = lc .resampled (3 )
6561 expected = np .array ([[0.0 , 0.2 , 1.0 , 0.7 ],
@@ -371,9 +367,7 @@ def test_BoundaryNorm():
371367 assert_array_equal (mynorm (x ), ref )
372368
373369 # Without interpolation
374- cmref = mcolors .ListedColormap (['blue' , 'red' ])
375- cmref .set_over ('black' )
376- cmref .set_under ('white' )
370+ cmref = mcolors .ListedColormap (['blue' , 'red' ], under = 'white' , over = 'black' )
377371 cmshould = mcolors .ListedColormap (['white' , 'blue' , 'red' , 'black' ])
378372
379373 assert mcolors .same_color (cmref .get_over (), 'black' )
@@ -395,8 +389,7 @@ def test_BoundaryNorm():
395389 assert_array_equal (cmshould (mynorm (x )), cmref (refnorm (x )))
396390
397391 # Just min
398- cmref = mcolors .ListedColormap (['blue' , 'red' ])
399- cmref .set_under ('white' )
392+ cmref = mcolors .ListedColormap (['blue' , 'red' ], under = 'white' )
400393 cmshould = mcolors .ListedColormap (['white' , 'blue' , 'red' ])
401394
402395 assert mcolors .same_color (cmref .get_under (), 'white' )
@@ -413,8 +406,7 @@ def test_BoundaryNorm():
413406 assert_array_equal (cmshould (mynorm (x )), cmref (refnorm (x )))
414407
415408 # Just max
416- cmref = mcolors .ListedColormap (['blue' , 'red' ])
417- cmref .set_over ('black' )
409+ cmref = mcolors .ListedColormap (['blue' , 'red' ], over = 'black' )
418410 cmshould = mcolors .ListedColormap (['blue' , 'red' , 'black' ])
419411
420412 assert mcolors .same_color (cmref .get_over (), 'black' )
@@ -928,7 +920,7 @@ def test_cmap_and_norm_from_levels_and_colors2():
928920 for extend , i1 , cases in tests :
929921 cmap , norm = mcolors .from_levels_and_colors (levels , colors [0 :i1 ],
930922 extend = extend )
931- cmap . set_bad ( bad )
923+ cmap = cmap . with_extremes ( bad = bad )
932924 for d_val , expected_color in cases .items ():
933925 if d_val == masked_value :
934926 d_val = np .ma .array ([1 ], mask = True )
0 commit comments