@@ -303,6 +303,9 @@ def test_BoundaryNorm():
303
303
cmref .set_under ('white' )
304
304
cmshould = mcolors .ListedColormap (['white' , 'blue' , 'red' , 'black' ])
305
305
306
+ assert_array_equal (cmref .get_over (), mcolors .to_rgba ('black' ))
307
+ assert_array_equal (cmref .get_under (), mcolors .to_rgba ('white' ))
308
+
306
309
refnorm = mcolors .BoundaryNorm (bounds , cmref .N )
307
310
mynorm = mcolors .BoundaryNorm (bounds , cmshould .N , extend = 'both' )
308
311
assert mynorm .vmin == refnorm .vmin
@@ -323,6 +326,8 @@ def test_BoundaryNorm():
323
326
cmref .set_under ('white' )
324
327
cmshould = mcolors .ListedColormap (['white' , 'blue' , 'red' ])
325
328
329
+ assert_array_equal (cmref .get_under (), mcolors .to_rgba ('white' ))
330
+
326
331
assert cmref .N == 2
327
332
assert cmshould .N == 3
328
333
refnorm = mcolors .BoundaryNorm (bounds , cmref .N )
@@ -339,6 +344,8 @@ def test_BoundaryNorm():
339
344
cmref .set_over ('black' )
340
345
cmshould = mcolors .ListedColormap (['blue' , 'red' , 'black' ])
341
346
347
+ assert_array_equal (cmref .get_over (), mcolors .to_rgba ('black' ))
348
+
342
349
assert cmref .N == 2
343
350
assert cmshould .N == 3
344
351
refnorm = mcolors .BoundaryNorm (bounds , cmref .N )
@@ -1161,3 +1168,9 @@ def test_repr_html():
1161
1168
html = cmap ._repr_html_ ()
1162
1169
assert len (html ) > 0
1163
1170
assert cmap .name in html
1171
+
1172
+ def test_get_under_over_bad ():
1173
+ cmap = plt .get_cmap ('viridis' )
1174
+ assert_array_equal (cmap .get_under (), cmap (0.0 ))
1175
+ assert_array_equal (cmap .get_over (), cmap (1.0 ))
1176
+ assert_array_equal (cmap .get_bad (), cmap (np .nan ))
0 commit comments