99from .helper import (
1010 assert_deep_equal ,
1111 assert_image_equal ,
12- is_big_endian ,
1312 hopper ,
13+ is_big_endian ,
1414)
1515
1616pyarrow = pytest .importorskip ("pyarrow" , reason = "PyArrow not installed" )
@@ -37,7 +37,10 @@ def _test_img_equals_pyarray(
3737 if elts_per_pixel == 1 :
3838 assert pixel [ix ] == arr [y * img .width + x ].as_py ()[elt ]
3939 else :
40- assert pixel [ix ] == arr [(y * img .width + x ) * elts_per_pixel + elt ].as_py ()
40+ assert (
41+ pixel [ix ]
42+ == arr [(y * img .width + x ) * elts_per_pixel + elt ].as_py ()
43+ )
4144 else :
4245 assert_deep_equal (px [x , y ], arr [y * img .width + x ].as_py ())
4346
@@ -169,33 +172,27 @@ def test_lifetime2() -> None:
169172 "mode, data_tp, mask" ,
170173 (
171174 ("L" , (pyarrow .uint8 (), 3 , 1 ), None ),
172- ("I" , (pyarrow .int32 (), 1 << 24 , 1 ), None ),
175+ ("I" , (pyarrow .int32 (), 1 << 24 , 1 ), None ),
173176 ("F" , (pyarrow .float32 (), 3.14159 , 1 ), None ),
174177 ("LA" , UINT_ARR , [0 , 3 ]),
175178 ("LA" , UINT , [0 , 3 ]),
176179 ("RGB" , UINT_ARR , [0 , 1 , 2 ]),
177180 ("RGBA" , UINT_ARR , None ),
178- ("RGBA" , UINT_ARR , None ),
179181 ("CMYK" , UINT_ARR , None ),
180- ("YCbCr" , UINT_ARR , [0 , 1 , 2 ]),
181- ("HSV" , UINT_ARR , [0 , 1 , 2 ]),
182+ ("YCbCr" , UINT_ARR , [0 , 1 , 2 ]),
183+ ("HSV" , UINT_ARR , [0 , 1 , 2 ]),
182184 ("RGB" , UINT , [0 , 1 , 2 ]),
183185 ("RGBA" , UINT , None ),
184- ("RGBA" , UINT , None ),
185186 ("CMYK" , UINT , None ),
186- ("YCbCr" , UINT , [0 , 1 , 2 ]),
187- ("HSV" , UINT , [0 , 1 , 2 ]),
187+ ("YCbCr" , UINT , [0 , 1 , 2 ]),
188+ ("HSV" , UINT , [0 , 1 , 2 ]),
188189 ),
189190)
190- def test_fromarray (mode : str ,
191- data_tp : tuple ,
192- mask :list [int ] | None ) -> None :
193- (dtype ,
194- elt ,
195- elts_per_pixel ) = data_tp
191+ def test_fromarray (mode : str , data_tp : tuple , mask : list [int ] | None ) -> None :
192+ (dtype , elt , elts_per_pixel ) = data_tp
196193
197194 ct_pixels = TEST_IMAGE_SIZE [0 ] * TEST_IMAGE_SIZE [1 ]
198- arr = pyarrow .array ([elt ]* (ct_pixels * elts_per_pixel ), type = dtype )
195+ arr = pyarrow .array ([elt ] * (ct_pixels * elts_per_pixel ), type = dtype )
199196 img = Image .fromarrow (arr , mode , TEST_IMAGE_SIZE )
200197
201198 _test_img_equals_pyarray (img , arr , mask , elts_per_pixel )
@@ -207,21 +204,16 @@ def test_fromarray(mode: str,
207204 ("LA" , INT32 , [0 , 3 ]),
208205 ("RGB" , INT32 , [0 , 1 , 2 ]),
209206 ("RGBA" , INT32 , None ),
210- ("RGBA" , INT32 , None ),
211207 ("CMYK" , INT32 , None ),
212- ("YCbCr" , INT32 , [0 , 1 , 2 ]),
213- ("HSV" , INT32 , [0 , 1 , 2 ]),
208+ ("YCbCr" , INT32 , [0 , 1 , 2 ]),
209+ ("HSV" , INT32 , [0 , 1 , 2 ]),
214210 ),
215211)
216- def test_from_int32array (mode : str ,
217- data_tp : tuple ,
218- mask :list [int ] | None ) -> None :
219- (dtype ,
220- elt ,
221- elts_per_pixel ) = data_tp
212+ def test_from_int32array (mode : str , data_tp : tuple , mask : list [int ] | None ) -> None :
213+ (dtype , elt , elts_per_pixel ) = data_tp
222214
223215 ct_pixels = TEST_IMAGE_SIZE [0 ] * TEST_IMAGE_SIZE [1 ]
224- arr = pyarrow .array ([elt ]* (ct_pixels * elts_per_pixel ), type = dtype )
216+ arr = pyarrow .array ([elt ] * (ct_pixels * elts_per_pixel ), type = dtype )
225217 img = Image .fromarrow (arr , mode , TEST_IMAGE_SIZE )
226218
227219 _test_img_equals_int32_pyarray (img , arr , mask , elts_per_pixel )
0 commit comments