@@ -150,21 +150,24 @@ def test_imsave_color_alpha():
150150 # acceptably preserved through a save/read roundtrip.
151151 from numpy import random
152152 random .seed (1 )
153- data = random .rand (16 , 16 , 4 )
154153
155- buff = io .BytesIO ()
156- plt .imsave (buff , data )
154+ for origin in ['lower' , 'upper' ]:
155+ data = random .rand (16 , 16 , 4 )
156+ buff = io .BytesIO ()
157+ plt .imsave (buff , data , origin = origin )
157158
158- buff .seek (0 )
159- arr_buf = plt .imread (buff )
159+ buff .seek (0 )
160+ arr_buf = plt .imread (buff )
160161
161- # Recreate the float -> uint8 conversion of the data
162- # We can only expect to be the same with 8 bits of precision,
163- # since that's what the PNG file used.
164- data = (255 * data ).astype ('uint8' )
165- arr_buf = (255 * arr_buf ).astype ('uint8' )
162+ # Recreate the float -> uint8 conversion of the data
163+ # We can only expect to be the same with 8 bits of precision,
164+ # since that's what the PNG file used.
165+ data = (255 * data ).astype ('uint8' )
166+ if origin == 'lower' :
167+ data = data [::- 1 ]
168+ arr_buf = (255 * arr_buf ).astype ('uint8' )
166169
167- assert_array_equal (data , arr_buf )
170+ assert_array_equal (data , arr_buf )
168171
169172@image_comparison (baseline_images = ['image_alpha' ], remove_text = True )
170173def test_image_alpha ():
0 commit comments