@@ -53,13 +53,9 @@ def test_resampled():
53
53
colorlist [:, 1 ] = 0.2
54
54
colorlist [:, 2 ] = np .linspace (1 , 0 , n )
55
55
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' )
63
59
lsc3 = lsc .resampled (3 )
64
60
lc3 = lc .resampled (3 )
65
61
expected = np .array ([[0.0 , 0.2 , 1.0 , 0.7 ],
@@ -371,9 +367,7 @@ def test_BoundaryNorm():
371
367
assert_array_equal (mynorm (x ), ref )
372
368
373
369
# 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' )
377
371
cmshould = mcolors .ListedColormap (['white' , 'blue' , 'red' , 'black' ])
378
372
379
373
assert mcolors .same_color (cmref .get_over (), 'black' )
@@ -395,8 +389,7 @@ def test_BoundaryNorm():
395
389
assert_array_equal (cmshould (mynorm (x )), cmref (refnorm (x )))
396
390
397
391
# Just min
398
- cmref = mcolors .ListedColormap (['blue' , 'red' ])
399
- cmref .set_under ('white' )
392
+ cmref = mcolors .ListedColormap (['blue' , 'red' ], under = 'white' )
400
393
cmshould = mcolors .ListedColormap (['white' , 'blue' , 'red' ])
401
394
402
395
assert mcolors .same_color (cmref .get_under (), 'white' )
@@ -413,8 +406,7 @@ def test_BoundaryNorm():
413
406
assert_array_equal (cmshould (mynorm (x )), cmref (refnorm (x )))
414
407
415
408
# Just max
416
- cmref = mcolors .ListedColormap (['blue' , 'red' ])
417
- cmref .set_over ('black' )
409
+ cmref = mcolors .ListedColormap (['blue' , 'red' ], over = 'black' )
418
410
cmshould = mcolors .ListedColormap (['blue' , 'red' , 'black' ])
419
411
420
412
assert mcolors .same_color (cmref .get_over (), 'black' )
@@ -928,7 +920,7 @@ def test_cmap_and_norm_from_levels_and_colors2():
928
920
for extend , i1 , cases in tests :
929
921
cmap , norm = mcolors .from_levels_and_colors (levels , colors [0 :i1 ],
930
922
extend = extend )
931
- cmap . set_bad ( bad )
923
+ cmap = cmap . with_extremes ( bad = bad )
932
924
for d_val , expected_color in cases .items ():
933
925
if d_val == masked_value :
934
926
d_val = np .ma .array ([1 ], mask = True )
0 commit comments