@@ -150,21 +150,24 @@ def test_imsave_color_alpha():
150
150
# acceptably preserved through a save/read roundtrip.
151
151
from numpy import random
152
152
random .seed (1 )
153
- data = random .rand (16 , 16 , 4 )
154
153
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 )
157
158
158
- buff .seek (0 )
159
- arr_buf = plt .imread (buff )
159
+ buff .seek (0 )
160
+ arr_buf = plt .imread (buff )
160
161
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' )
166
169
167
- assert_array_equal (data , arr_buf )
170
+ assert_array_equal (data , arr_buf )
168
171
169
172
@image_comparison (baseline_images = ['image_alpha' ], remove_text = True )
170
173
def test_image_alpha ():
0 commit comments