mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-07 14:43:16 +03:00
Test Typing, consistency/style issues
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
parent
42d0682a37
commit
48bbc64c72
|
@ -37,7 +37,7 @@ python3 -m pip install -U pytest-cov
|
||||||
python3 -m pip install -U pytest-timeout
|
python3 -m pip install -U pytest-timeout
|
||||||
python3 -m pip install pyroma
|
python3 -m pip install pyroma
|
||||||
# optional test dependency, only install if there's a binary package.
|
# optional test dependency, only install if there's a binary package.
|
||||||
# fails on beta 3.14 and pypy3.10
|
# fails on beta 3.14 and PyPy
|
||||||
python3 -m pip install --only-binary=:all: pyarrow || true
|
python3 -m pip install --only-binary=:all: pyarrow || true
|
||||||
|
|
||||||
if [[ $(uname) != CYGWIN* ]]; then
|
if [[ $(uname) != CYGWIN* ]]; then
|
||||||
|
|
2
.github/workflows/macos-install.sh
vendored
2
.github/workflows/macos-install.sh
vendored
|
@ -27,7 +27,7 @@ python3 -m pip install -U pytest-timeout
|
||||||
python3 -m pip install pyroma
|
python3 -m pip install pyroma
|
||||||
python3 -m pip install numpy
|
python3 -m pip install numpy
|
||||||
# optional test dependency, only install if there's a binary package.
|
# optional test dependency, only install if there's a binary package.
|
||||||
# fails on beta 3.14 and pypy3.10
|
# fails on beta 3.14 and PyPy
|
||||||
python3 -m pip install --only-binary=:all: pyarrow || true
|
python3 -m pip install --only-binary=:all: pyarrow || true
|
||||||
|
|
||||||
# extra test images
|
# extra test images
|
||||||
|
|
|
@ -11,7 +11,7 @@ from .helper import hopper
|
||||||
"mode, dest_modes",
|
"mode, dest_modes",
|
||||||
(
|
(
|
||||||
("L", ["I", "F", "LA", "RGB", "RGBA", "RGBX", "CMYK", "YCbCr", "HSV"]),
|
("L", ["I", "F", "LA", "RGB", "RGBA", "RGBX", "CMYK", "YCbCr", "HSV"]),
|
||||||
("I", ["L", "F"]), # Technically I32 can work for any 4x8bit storage.
|
("I", ["L", "F"]), # Technically I;32 can work for any 4x8bit storage.
|
||||||
("F", ["I", "L", "LA", "RGB", "RGBA", "RGBX", "CMYK", "YCbCr", "HSV"]),
|
("F", ["I", "L", "LA", "RGB", "RGBA", "RGBX", "CMYK", "YCbCr", "HSV"]),
|
||||||
("LA", ["L", "F"]),
|
("LA", ["L", "F"]),
|
||||||
("RGB", ["L", "F"]),
|
("RGB", ["L", "F"]),
|
||||||
|
@ -29,7 +29,7 @@ def test_invalid_array_type(mode: str, dest_modes: list[str]) -> None:
|
||||||
Image.fromarrow(img, dest_mode, img.size)
|
Image.fromarrow(img, dest_mode, img.size)
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_array_size():
|
def test_invalid_array_size() -> None:
|
||||||
img = hopper("RGB")
|
img = hopper("RGB")
|
||||||
|
|
||||||
assert img.size != (10, 10)
|
assert img.size != (10, 10)
|
||||||
|
@ -37,14 +37,14 @@ def test_invalid_array_size():
|
||||||
Image.fromarrow(img, "RGB", (10, 10))
|
Image.fromarrow(img, "RGB", (10, 10))
|
||||||
|
|
||||||
|
|
||||||
def test_release_schema():
|
def test_release_schema() -> None:
|
||||||
# these should not error out, valgrind should be clean
|
# these should not error out, valgrind should be clean
|
||||||
img = hopper("L")
|
img = hopper("L")
|
||||||
schema = img.__arrow_c_schema__()
|
schema = img.__arrow_c_schema__()
|
||||||
del schema
|
del schema
|
||||||
|
|
||||||
|
|
||||||
def test_release_array():
|
def test_release_array() -> None:
|
||||||
# these should not error out, valgrind should be clean
|
# these should not error out, valgrind should be clean
|
||||||
img = hopper("L")
|
img = hopper("L")
|
||||||
array, schema = img.__arrow_c_array__()
|
array, schema = img.__arrow_c_array__()
|
||||||
|
@ -52,7 +52,7 @@ def test_release_array():
|
||||||
del schema
|
del schema
|
||||||
|
|
||||||
|
|
||||||
def test_readonly():
|
def test_readonly() -> None:
|
||||||
img = hopper("L")
|
img = hopper("L")
|
||||||
reloaded = Image.fromarrow(img, img.mode, img.size)
|
reloaded = Image.fromarrow(img, img.mode, img.size)
|
||||||
assert reloaded.readonly == 1
|
assert reloaded.readonly == 1
|
||||||
|
@ -60,7 +60,7 @@ def test_readonly():
|
||||||
assert reloaded.readonly == 1
|
assert reloaded.readonly == 1
|
||||||
|
|
||||||
|
|
||||||
def test_multiblock_l_image():
|
def test_multiblock_l_image() -> None:
|
||||||
block_size = Image.core.get_block_size()
|
block_size = Image.core.get_block_size()
|
||||||
|
|
||||||
# check a 2 block image in single channel mode
|
# check a 2 block image in single channel mode
|
||||||
|
@ -71,7 +71,7 @@ def test_multiblock_l_image():
|
||||||
(schema, arr) = img.__arrow_c_array__()
|
(schema, arr) = img.__arrow_c_array__()
|
||||||
|
|
||||||
|
|
||||||
def test_multiblock_rgba_image():
|
def test_multiblock_rgba_image() -> None:
|
||||||
block_size = Image.core.get_block_size()
|
block_size = Image.core.get_block_size()
|
||||||
|
|
||||||
# check a 2 block image in 4 channel mode
|
# check a 2 block image in 4 channel mode
|
||||||
|
@ -82,7 +82,7 @@ def test_multiblock_rgba_image():
|
||||||
(schema, arr) = img.__arrow_c_array__()
|
(schema, arr) = img.__arrow_c_array__()
|
||||||
|
|
||||||
|
|
||||||
def test_multiblock_l_schema():
|
def test_multiblock_l_schema() -> None:
|
||||||
block_size = Image.core.get_block_size()
|
block_size = Image.core.get_block_size()
|
||||||
|
|
||||||
# check a 2 block image in single channel mode
|
# check a 2 block image in single channel mode
|
||||||
|
@ -93,7 +93,7 @@ def test_multiblock_l_schema():
|
||||||
img.__arrow_c_schema__()
|
img.__arrow_c_schema__()
|
||||||
|
|
||||||
|
|
||||||
def test_multiblock_rgba_schema():
|
def test_multiblock_rgba_schema() -> None:
|
||||||
block_size = Image.core.get_block_size()
|
block_size = Image.core.get_block_size()
|
||||||
|
|
||||||
# check a 2 block image in 4 channel mode
|
# check a 2 block image in 4 channel mode
|
||||||
|
@ -104,7 +104,7 @@ def test_multiblock_rgba_schema():
|
||||||
img.__arrow_c_schema__()
|
img.__arrow_c_schema__()
|
||||||
|
|
||||||
|
|
||||||
def test_singleblock_l_image():
|
def test_singleblock_l_image() -> None:
|
||||||
Image.core.set_use_block_allocator(1)
|
Image.core.set_use_block_allocator(1)
|
||||||
|
|
||||||
block_size = Image.core.get_block_size()
|
block_size = Image.core.get_block_size()
|
||||||
|
@ -121,7 +121,7 @@ def test_singleblock_l_image():
|
||||||
Image.core.set_use_block_allocator(0)
|
Image.core.set_use_block_allocator(0)
|
||||||
|
|
||||||
|
|
||||||
def test_singleblock_rgba_image():
|
def test_singleblock_rgba_image() -> None:
|
||||||
Image.core.set_use_block_allocator(1)
|
Image.core.set_use_block_allocator(1)
|
||||||
block_size = Image.core.get_block_size()
|
block_size = Image.core.get_block_size()
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ def test_singleblock_rgba_image():
|
||||||
Image.core.set_use_block_allocator(0)
|
Image.core.set_use_block_allocator(0)
|
||||||
|
|
||||||
|
|
||||||
def test_singleblock_l_schema():
|
def test_singleblock_l_schema() -> None:
|
||||||
Image.core.set_use_block_allocator(1)
|
Image.core.set_use_block_allocator(1)
|
||||||
block_size = Image.core.get_block_size()
|
block_size = Image.core.get_block_size()
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ def test_singleblock_l_schema():
|
||||||
Image.core.set_use_block_allocator(0)
|
Image.core.set_use_block_allocator(0)
|
||||||
|
|
||||||
|
|
||||||
def test_singleblock_rgba_schema():
|
def test_singleblock_rgba_schema() -> None:
|
||||||
Image.core.set_use_block_allocator(1)
|
Image.core.set_use_block_allocator(1)
|
||||||
block_size = Image.core.get_block_size()
|
block_size = Image.core.get_block_size()
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ def test_to_array(mode: str, dtype: Any, mask: Any) -> None:
|
||||||
assert_image_equal(img, reloaded)
|
assert_image_equal(img, reloaded)
|
||||||
|
|
||||||
|
|
||||||
def test_lifetime():
|
def test_lifetime() -> None:
|
||||||
# valgrind shouldn't error out here.
|
# valgrind shouldn't error out here.
|
||||||
# arrays should be accessible after the image is deleted.
|
# arrays should be accessible after the image is deleted.
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ def test_lifetime():
|
||||||
del arr_2
|
del arr_2
|
||||||
|
|
||||||
|
|
||||||
def test_lifetime2():
|
def test_lifetime2() -> None:
|
||||||
# valgrind shouldn't error out here.
|
# valgrind shouldn't error out here.
|
||||||
# img should remain after the arrays are collected.
|
# img should remain after the arrays are collected.
|
||||||
|
|
||||||
|
|
|
@ -3325,7 +3325,7 @@ def fromarrow(obj: SupportsArrowArrayInterface, mode, size) -> Image:
|
||||||
|
|
||||||
As with array support, when converting Pillow images to arrays,
|
As with array support, when converting Pillow images to arrays,
|
||||||
only pixel values are transferred. This means that P and PA mode
|
only pixel values are transferred. This means that P and PA mode
|
||||||
image will lose their palette.
|
images will lose their palette.
|
||||||
|
|
||||||
:param obj: Object with an arrow_c_array interface
|
:param obj: Object with an arrow_c_array interface
|
||||||
:param mode: Image mode.
|
:param mode: Image mode.
|
||||||
|
|
|
@ -291,7 +291,6 @@ ExportArrowArrayPyCapsule(ImagingObject *self) {
|
||||||
return PyCapsule_New(array, "arrow_array", ReleaseArrowArrayPyCapsule);
|
return PyCapsule_New(array, "arrow_array", ReleaseArrowArrayPyCapsule);
|
||||||
}
|
}
|
||||||
free(array);
|
free(array);
|
||||||
// raise error here
|
|
||||||
return ArrowError(err);
|
return ArrowError(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -572,7 +572,7 @@ ImagingAllocateBlock(Imaging im) {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ImagingDestroyArrow(Imaging im) {
|
ImagingDestroyArrow(Imaging im) {
|
||||||
// Rely on the internal python destructor for the array capsule.
|
// Rely on the internal Python destructor for the array capsule.
|
||||||
if (im->arrow_array_capsule) {
|
if (im->arrow_array_capsule) {
|
||||||
Py_DECREF(im->arrow_array_capsule);
|
Py_DECREF(im->arrow_array_capsule);
|
||||||
im->arrow_array_capsule = NULL;
|
im->arrow_array_capsule = NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user