Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4514171

Browse files
committed
Add tests for getters.
1 parent 2fd8ed0 commit 4514171

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/matplotlib/tests/test_colors.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ def test_BoundaryNorm():
303303
cmref.set_under('white')
304304
cmshould = mcolors.ListedColormap(['white', 'blue', 'red', 'black'])
305305

306+
assert_array_equal(cmref.get_over(), mcolors.to_rgba('black'))
307+
assert_array_equal(cmref.get_under(), mcolors.to_rgba('white'))
308+
306309
refnorm = mcolors.BoundaryNorm(bounds, cmref.N)
307310
mynorm = mcolors.BoundaryNorm(bounds, cmshould.N, extend='both')
308311
assert mynorm.vmin == refnorm.vmin
@@ -323,6 +326,8 @@ def test_BoundaryNorm():
323326
cmref.set_under('white')
324327
cmshould = mcolors.ListedColormap(['white', 'blue', 'red'])
325328

329+
assert_array_equal(cmref.get_under(), mcolors.to_rgba('white'))
330+
326331
assert cmref.N == 2
327332
assert cmshould.N == 3
328333
refnorm = mcolors.BoundaryNorm(bounds, cmref.N)
@@ -339,6 +344,8 @@ def test_BoundaryNorm():
339344
cmref.set_over('black')
340345
cmshould = mcolors.ListedColormap(['blue', 'red', 'black'])
341346

347+
assert_array_equal(cmref.get_over(), mcolors.to_rgba('black'))
348+
342349
assert cmref.N == 2
343350
assert cmshould.N == 3
344351
refnorm = mcolors.BoundaryNorm(bounds, cmref.N)
@@ -1161,3 +1168,9 @@ def test_repr_html():
11611168
html = cmap._repr_html_()
11621169
assert len(html) > 0
11631170
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

Comments
 (0)