@@ -281,6 +281,33 @@ def test_imshow_alpha(fig_test, fig_ref):
281281 ax3 .imshow (rgbau )
282282
283283
284+ @pytest .mark .parametrize ('n_channels, is_int, alpha_arr, opaque' ,
285+ [(3 , False , False , False ), # RGB float
286+ (4 , False , False , False ), # RGBA float
287+ (4 , False , True , False ), # RGBA float with alpha array
288+ (4 , False , False , True ), # RGBA float with solid color
289+ (4 , True , False , False )]) # RGBA unint8
290+ def test_imshow_multi_draw (n_channels , is_int , alpha_arr , opaque ):
291+ if is_int :
292+ array = np .random .randint (0 , 256 , (2 , 2 , n_channels ))
293+ else :
294+ array = np .random .random ((2 , 2 , n_channels ))
295+ if opaque :
296+ array [:, :, 3 ] = 1
297+
298+ if alpha_arr :
299+ alpha = np .array ([[0.3 , 0.5 ], [1 , 0.8 ]])
300+ else :
301+ alpha = None
302+
303+ fig , ax = plt .subplots ()
304+ im = ax .imshow (array , alpha = alpha )
305+ fig .draw_without_rendering ()
306+
307+ # Draw should not modify original array
308+ np .testing .assert_array_equal (array , im ._A )
309+
310+
284311def test_cursor_data ():
285312 from matplotlib .backend_bases import MouseEvent
286313
0 commit comments