[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2025-02-03 17:43:07 +00:00
parent 240175733e
commit be3b0fd05c
3 changed files with 24 additions and 15 deletions

View File

@ -170,6 +170,7 @@ def test_multiblock_l_image():
with pytest.raises(ValueError): with pytest.raises(ValueError):
(schema, arr) = img.__arrow_c_array__() (schema, arr) = img.__arrow_c_array__()
def test_multiblock_rgba_image(): def test_multiblock_rgba_image():
block_size = Image.core.get_block_size() block_size = Image.core.get_block_size()
@ -191,6 +192,7 @@ def test_multiblock_l_schema():
with pytest.raises(ValueError): with pytest.raises(ValueError):
schema = img.__arrow_c_schema__() schema = img.__arrow_c_schema__()
def test_multiblock_rgba_schema(): def test_multiblock_rgba_schema():
block_size = Image.core.get_block_size() block_size = Image.core.get_block_size()
@ -209,7 +211,7 @@ def test_singleblock_l_image():
# check a 2 block image in 4 channel mode # check a 2 block image in 4 channel mode
size = (4096, 2 * (block_size // 4096)) size = (4096, 2 * (block_size // 4096))
img = Image.new('L', size, 128) img = Image.new("L", size, 128)
assert img.im.isblock() assert img.im.isblock()
(schema, arr) = img.__arrow_c_array__() (schema, arr) = img.__arrow_c_array__()
@ -218,13 +220,14 @@ 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():
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()
# check a 2 block image in 4 channel mode # check a 2 block image in 4 channel mode
size = (4096, (block_size // 4096) // 2) size = (4096, (block_size // 4096) // 2)
img = Image.new('RGBA', size, (128,127,126,125)) img = Image.new("RGBA", size, (128, 127, 126, 125))
assert img.im.isblock() assert img.im.isblock()
(schema, arr) = img.__arrow_c_array__() (schema, arr) = img.__arrow_c_array__()
@ -239,20 +242,21 @@ def test_singleblock_l_schema():
# check a 2 block image in single channel mode # check a 2 block image in single channel mode
size = (4096, 2 * block_size // 4096) size = (4096, 2 * block_size // 4096)
img = Image.new('L', size, 128) img = Image.new("L", size, 128)
assert img.im.isblock() assert img.im.isblock()
schema = img.__arrow_c_schema__() schema = img.__arrow_c_schema__()
assert schema assert 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():
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()
# check a 2 block image in 4 channel mode # check a 2 block image in 4 channel mode
size = (4096, (block_size // 4096) // 2) size = (4096, (block_size // 4096) // 2)
img = Image.new('RGBA', size, (128,127,126,125)) img = Image.new("RGBA", size, (128, 127, 126, 125))
assert img.im.isblock() assert img.im.isblock()
schema = img.__arrow_c_schema__() schema = img.__arrow_c_schema__()

View File

@ -302,7 +302,9 @@ _new_arrow(PyObject *self, PyObject *args) {
} }
// ImagingBorrowArrow is responsible for retaining the array_capsule // ImagingBorrowArrow is responsible for retaining the array_capsule
ret = PyImagingNew(ImagingNewArrow(mode, xsize, ysize, schema_capsule, array_capsule)); ret =
PyImagingNew(ImagingNewArrow(mode, xsize, ysize, schema_capsule, array_capsule)
);
if (!ret) { if (!ret) {
return ImagingError_ValueError("Invalid arrow array mode or size mismatch"); return ImagingError_ValueError("Invalid arrow array mode or size mismatch");
} }
@ -4202,7 +4204,6 @@ _set_use_block_allocator(PyObject *self, PyObject *args) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static PyObject * static PyObject *
_get_use_block_allocator(PyObject *self, PyObject *args) { _get_use_block_allocator(PyObject *self, PyObject *args) {
return PyLong_FromLong(ImagingDefaultArena.use_block_allocator); return PyLong_FromLong(ImagingDefaultArena.use_block_allocator);

View File

@ -379,7 +379,6 @@ ImagingMemorySetBlockAllocator(ImagingMemoryArena arena, int use_block_allocator
arena->use_block_allocator = use_block_allocator; arena->use_block_allocator = use_block_allocator;
} }
void void
ImagingMemoryClearCache(ImagingMemoryArena arena, int new_size) { ImagingMemoryClearCache(ImagingMemoryArena arena, int new_size) {
while (arena->blocks_cached > new_size) { while (arena->blocks_cached > new_size) {
@ -581,7 +580,12 @@ ImagingDestroyArrow(Imaging im) {
} }
Imaging Imaging
ImagingBorrowArrow(Imaging im, struct ArrowArray *external_array, int offset_width, PyObject* arrow_capsule) { ImagingBorrowArrow(
Imaging im,
struct ArrowArray *external_array,
int offset_width,
PyObject *arrow_capsule
) {
// offset_width is the # of char* for a single offset from arrow // offset_width is the # of char* for a single offset from arrow
Py_ssize_t y, i; Py_ssize_t y, i;