@@ -161,21 +161,24 @@ def test_imsave_color_alpha():
161161 # acceptably preserved through a save/read roundtrip.
162162 from numpy import random
163163 random .seed (1 )
164- data = random .rand (16 , 16 , 4 )
165164
166- buff = io .BytesIO ()
167- plt .imsave (buff , data )
165+ for origin in ['lower' , 'upper' ]:
166+ data = random .rand (16 , 16 , 4 )
167+ buff = io .BytesIO ()
168+ plt .imsave (buff , data , origin = origin )
168169
169- buff .seek (0 )
170- arr_buf = plt .imread (buff )
170+ buff .seek (0 )
171+ arr_buf = plt .imread (buff )
171172
172- # Recreate the float -> uint8 conversion of the data
173- # We can only expect to be the same with 8 bits of precision,
174- # since that's what the PNG file used.
175- data = (255 * data ).astype ('uint8' )
176- arr_buf = (255 * arr_buf ).astype ('uint8' )
173+ # Recreate the float -> uint8 conversion of the data
174+ # We can only expect to be the same with 8 bits of precision,
175+ # since that's what the PNG file used.
176+ data = (255 * data ).astype ('uint8' )
177+ if origin == 'lower' :
178+ data = data [::- 1 ]
179+ arr_buf = (255 * arr_buf ).astype ('uint8' )
177180
178- assert_array_equal (data , arr_buf )
181+ assert_array_equal (data , arr_buf )
179182
180183@image_comparison (baseline_images = ['image_alpha' ], remove_text = True )
181184def test_image_alpha ():
0 commit comments