Skip to content

Commit

Permalink
Merge pull request #8733 from radarhere/tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Feb 6, 2025
2 parents dd2bb39 + a37702d commit c73796d
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 26 deletions.
20 changes: 9 additions & 11 deletions Tests/test_color_lut.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class TestColorLut3DCoreAPI:
def generate_identity_table(
self, channels: int, size: int | tuple[int, int, int]
) -> tuple[int, int, int, int, list[float]]:
) -> tuple[int, tuple[int, int, int], list[float]]:
if isinstance(size, tuple):
size_1d, size_2d, size_3d = size
else:
Expand All @@ -39,9 +39,7 @@ def generate_identity_table(
]
return (
channels,
size_1d,
size_2d,
size_3d,
(size_1d, size_2d, size_3d),
[item for sublist in table for item in sublist],
)

Expand Down Expand Up @@ -89,21 +87,21 @@ def test_wrong_args(self) -> None:

with pytest.raises(ValueError, match=r"size1D \* size2D \* size3D"):
im.im.color_lut_3d(
"RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, 0] * 7
"RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), [0, 0, 0] * 7
)

with pytest.raises(ValueError, match=r"size1D \* size2D \* size3D"):
im.im.color_lut_3d(
"RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, 0] * 9
"RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), [0, 0, 0] * 9
)

with pytest.raises(TypeError):
im.im.color_lut_3d(
"RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, [0, 0, "0"] * 8
"RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), [0, 0, "0"] * 8
)

with pytest.raises(TypeError):
im.im.color_lut_3d("RGB", Image.Resampling.BILINEAR, 3, 2, 2, 2, 16)
im.im.color_lut_3d("RGB", Image.Resampling.BILINEAR, 3, (2, 2, 2), 16)

@pytest.mark.parametrize(
"lut_mode, table_channels, table_size",
Expand Down Expand Up @@ -264,7 +262,7 @@ def test_channels_order(self) -> None:
assert_image_equal(
Image.merge('RGB', im.split()[::-1]),
im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR,
3, 2, 2, 2, [
3, (2, 2, 2), [
0, 0, 0, 0, 0, 1,
0, 1, 0, 0, 1, 1,

Expand All @@ -286,7 +284,7 @@ def test_overflow(self) -> None:

# fmt: off
transformed = im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR,
3, 2, 2, 2,
3, (2, 2, 2),
[
-1, -1, -1, 2, -1, -1,
-1, 2, -1, 2, 2, -1,
Expand All @@ -307,7 +305,7 @@ def test_overflow(self) -> None:

# fmt: off
transformed = im._new(im.im.color_lut_3d('RGB', Image.Resampling.BILINEAR,
3, 2, 2, 2,
3, (2, 2, 2),
[
-3, -3, -3, 5, -3, -3,
-3, 5, -3, 5, 5, -3,
Expand Down
4 changes: 1 addition & 3 deletions src/PIL/ImageFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,6 @@ def filter(self, image: _imaging.ImagingCore) -> _imaging.ImagingCore:
self.mode or image.mode,
Image.Resampling.BILINEAR,
self.channels,
self.size[0],
self.size[1],
self.size[2],
self.size,
self.table,
)
3 changes: 1 addition & 2 deletions src/PIL/ImageFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,7 @@ def fill(width: int, height: int) -> Image.core.ImagingCore:
kwargs.get("stroke_filled", False),
anchor,
ink,
start[0],
start[1],
start,
)

def font_variant(
Expand Down
3 changes: 1 addition & 2 deletions src/PIL/JpegImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,7 @@ def validate_qtables(
optimize,
info.get("keep_rgb", False),
info.get("streamtype", 0),
dpi[0],
dpi[1],
dpi,
subsampling,
info.get("restart_marker_blocks", 0),
info.get("restart_marker_rows", 0),
Expand Down
3 changes: 1 addition & 2 deletions src/PIL/WebPImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ def _save_all(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:

# Setup the WebP animation encoder
enc = _webp.WebPAnimEncoder(
im.size[0],
im.size[1],
im.size,
background,
loop,
minimize_size,
Expand Down
3 changes: 1 addition & 2 deletions src/PIL/_imagingft.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class Font:
stroke_filled: bool,
anchor: str | None,
foreground_ink_long: int,
x_start: float,
y_start: float,
start: tuple[float, float],
/,
) -> tuple[_imaging.ImagingCore, tuple[int, int]]: ...
def getsize(
Expand Down
2 changes: 1 addition & 1 deletion src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ _color_lut_3d(ImagingObject *self, PyObject *args) {

if (!PyArg_ParseTuple(
args,
"siiiiiO:color_lut_3d",
"sii(iii)O:color_lut_3d",
&mode,
&filter,
&table_channels,
Expand Down
2 changes: 1 addition & 1 deletion src/_imagingft.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ font_render(FontObject *self, PyObject *args) {

if (!PyArg_ParseTuple(
args,
"OO|zzOzfpzLffO:render",
"OO|zzOzfpzL(ff):render",
&string,
&fill,
&mode,
Expand Down
2 changes: 1 addition & 1 deletion src/_webp.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ _anim_encoder_new(PyObject *self, PyObject *args) {

if (!PyArg_ParseTuple(
args,
"iiIiiiiii",
"(ii)Iiiiiii",
&width,
&height,
&bgcolor,
Expand Down
2 changes: 1 addition & 1 deletion src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ PyImaging_JpegEncoderNew(PyObject *self, PyObject *args) {

if (!PyArg_ParseTuple(
args,
"ss|nnnnpnnnnnnOz#y#y#",
"ss|nnnnpn(nn)nnnOz#y#y#",
&mode,
&rawmode,
&quality,
Expand Down

0 comments on commit c73796d

Please sign in to comment.