mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-10 16:40:51 +03:00
merge test_putdata_mode_I() and test_putdata_mode_F() as test_putdata_scale_and_offset()
This commit is contained in:
parent
c9d7beaed0
commit
28731adcbe
|
@ -86,24 +86,23 @@ def test_putdata_mode_with_L_with_float() -> None:
|
||||||
assert im.getpixel((0, 0)) == 2
|
assert im.getpixel((0, 0)) == 2
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("mode", ("I", "I;16", "I;16L", "I;16B"))
|
@pytest.mark.parametrize(
|
||||||
def test_putdata_mode_I(mode: str) -> None:
|
"mode, scale, offset",
|
||||||
|
(
|
||||||
|
("I", 2, 256),
|
||||||
|
("I;16", 2, 256),
|
||||||
|
("I;16L", 2, 256),
|
||||||
|
("I;16B", 2, 256),
|
||||||
|
("F", 2.0, 256.0),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
def test_putdata_scale_and_offset(mode: str, scale: float, offset: float) -> None:
|
||||||
src = hopper("L")
|
src = hopper("L")
|
||||||
data = list(src.getdata())
|
data = list(src.getdata())
|
||||||
im = Image.new(mode, src.size, 0)
|
im = Image.new(mode, src.size, 0)
|
||||||
im.putdata(data, 2, 256)
|
im.putdata(data, scale, offset)
|
||||||
|
|
||||||
target = [2 * elt + 256 for elt in data]
|
target = [scale * val + offset for val in data]
|
||||||
assert list(im.getdata()) == target
|
|
||||||
|
|
||||||
|
|
||||||
def test_putdata_mode_F() -> None:
|
|
||||||
src = hopper("L")
|
|
||||||
data = list(src.getdata())
|
|
||||||
im = Image.new("F", src.size, 0)
|
|
||||||
im.putdata(data, 2.0, 256.0)
|
|
||||||
|
|
||||||
target = [2.0 * float(elt) + 256.0 for elt in data]
|
|
||||||
assert list(im.getdata()) == target
|
assert list(im.getdata()) == target
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user