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

Skip to content

Commit 4d62e65

Browse files
committed
Add test
1 parent dbf3eed commit 4d62e65

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/matplotlib/tests/test_colors.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,16 @@ def test_conversions():
821821
hex_color
822822

823823

824+
def test_conversions_masked():
825+
x1 = np.ma.array(['k', 'b'], mask=[True, False])
826+
x2 = np.ma.array([[0, 0, 0, 1], [0, 0, 1, 1]])
827+
x2[0] = np.ma.masked
828+
assert mcolors.to_rgba(x1[0]) == (0, 0, 0, 0)
829+
assert_array_equal(mcolors.to_rgba_array(x1),
830+
[[0, 0, 0, 0], [0, 0, 1, 1]])
831+
assert_array_equal(mcolors.to_rgba_array(x2), mcolors.to_rgba_array(x1))
832+
833+
824834
def test_to_rgba_array_single_str():
825835
# single color name is valid
826836
assert_array_equal(mcolors.to_rgba_array("red"), [(1, 0, 0, 1)])

0 commit comments

Comments
 (0)