This commit is contained in:
wiredfool 2025-04-17 22:22:31 +01:00
parent c729d4e208
commit ac500460df
2 changed files with 23 additions and 31 deletions

View File

@ -9,8 +9,8 @@ from PIL import Image
from .helper import (
assert_deep_equal,
assert_image_equal,
is_big_endian,
hopper,
is_big_endian,
)
pyarrow = pytest.importorskip("pyarrow", reason="PyArrow not installed")
@ -37,7 +37,10 @@ def _test_img_equals_pyarray(
if elts_per_pixel == 1:
assert pixel[ix] == arr[y * img.width + x].as_py()[elt]
else:
assert pixel[ix] == arr[(y * img.width + x) * elts_per_pixel + elt].as_py()
assert (
pixel[ix]
== arr[(y * img.width + x) * elts_per_pixel + elt].as_py()
)
else:
assert_deep_equal(px[x, y], arr[y * img.width + x].as_py())
@ -175,24 +178,18 @@ INT32 = (
("LA", UINT, [0, 3]),
("RGB", UINT_ARR, [0, 1, 2]),
("RGBA", UINT_ARR, None),
("RGBA", UINT_ARR, None),
("CMYK", UINT_ARR, None),
("YCbCr", UINT_ARR, [0, 1, 2]),
("HSV", UINT_ARR, [0, 1, 2]),
("RGB", UINT, [0, 1, 2]),
("RGBA", UINT, None),
("RGBA", UINT, None),
("CMYK", UINT, None),
("YCbCr", UINT, [0, 1, 2]),
("HSV", UINT, [0, 1, 2]),
),
)
def test_fromarray(mode: str,
data_tp: tuple,
mask:list[int] | None) -> None:
(dtype,
elt,
elts_per_pixel) = data_tp
def test_fromarray(mode: str, data_tp: tuple, mask: list[int] | None) -> None:
(dtype, elt, elts_per_pixel) = data_tp
ct_pixels = TEST_IMAGE_SIZE[0] * TEST_IMAGE_SIZE[1]
arr = pyarrow.array([elt] * (ct_pixels * elts_per_pixel), type=dtype)
@ -207,18 +204,13 @@ def test_fromarray(mode: str,
("LA", INT32, [0, 3]),
("RGB", INT32, [0, 1, 2]),
("RGBA", INT32, None),
("RGBA", INT32, None),
("CMYK", INT32, None),
("YCbCr", INT32, [0, 1, 2]),
("HSV", INT32, [0, 1, 2]),
),
)
def test_from_int32array(mode: str,
data_tp: tuple,
mask:list[int] | None) -> None:
(dtype,
elt,
elts_per_pixel) = data_tp
def test_from_int32array(mode: str, data_tp: tuple, mask: list[int] | None) -> None:
(dtype, elt, elts_per_pixel) = data_tp
ct_pixels = TEST_IMAGE_SIZE[0] * TEST_IMAGE_SIZE[1]
arr = pyarrow.array([elt] * (ct_pixels * elts_per_pixel), type=dtype)