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

Skip to content

Commit 369ba34

Browse files
committed
Testing 2d to 1d conversion function in
colors.to_rgba() + Rebase with master + Change .reshape((-1)) to .reshape(-1)
1 parent a6f13e9 commit 369ba34

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/matplotlib/tests/test_colors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,3 +1211,10 @@ def test_colormap_bad_data_with_alpha():
12111211
assert_array_equal(c[0, 0], (0, 0, 0, 0))
12121212
c = cmap([[np.nan, 0.5], [0, 0]], alpha=np.full((2, 2), 0.5))
12131213
assert_array_equal(c[0, 0], (0, 0, 0, 0))
1214+
1215+
1216+
def test_2d_to_rgba():
1217+
color = np.array([0.1, 0.2, 0.3])
1218+
rgba_1d = mcolors.to_rgba(color.reshape(-1))
1219+
rgba_2d = mcolors.to_rgba(color.reshape((1, -1)))
1220+
assert rgba_1d == rgba_2d

0 commit comments

Comments
 (0)