@@ -77,8 +77,25 @@ def test_from_levels_and_cmap_seaborn_cmap():
7777
7878
7979def test_from_levels_and_cmap_colorstring ():
80- pytest .importorskip ("seaborn" )
8180
8281 levels = [1 , 2 , 3 ]
8382 cmap , norm = mpu .from_levels_and_cmap (levels , "0.1" )
8483 assert_cmap_norm (cmap , norm , levels , extend = "neither" )
84+
85+ np .testing .assert_equal (cmap .colors [0 ], np .array ([0.1 , 0.1 , 0.1 , 1.0 ]))
86+ np .testing .assert_equal (cmap .colors [1 ], np .array ([0.1 , 0.1 , 0.1 , 1.0 ]))
87+
88+
89+ def test_from_levels_and_cmap_color_list_explicit ():
90+
91+ levels = [1 , 2 , 3 , 4 , 5 ]
92+
93+ # ensure colors are repeated (although that can also be unexpected)
94+ cmap , norm = mpu .from_levels_and_cmap (levels , ["b" , "k" ])
95+
96+ assert_cmap_norm (cmap , norm , levels , extend = "neither" )
97+
98+ np .testing .assert_equal (cmap .colors [0 ], np .array ([0.0 , 0.0 , 1.0 , 1.0 ])) # blue
99+ np .testing .assert_equal (cmap .colors [1 ], np .array ([0.0 , 0.0 , 0.0 , 1.0 ])) # black
100+ np .testing .assert_equal (cmap .colors [2 ], np .array ([0.0 , 0.0 , 1.0 , 1.0 ])) # blue
101+ np .testing .assert_equal (cmap .colors [3 ], np .array ([0.0 , 0.0 , 0.0 , 1.0 ])) # black
0 commit comments