mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-03 20:53:08 +03:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
240175733e
commit
be3b0fd05c
|
@ -170,6 +170,7 @@ def test_multiblock_l_image():
|
|||
with pytest.raises(ValueError):
|
||||
(schema, arr) = img.__arrow_c_array__()
|
||||
|
||||
|
||||
def test_multiblock_rgba_image():
|
||||
block_size = Image.core.get_block_size()
|
||||
|
||||
|
@ -191,6 +192,7 @@ def test_multiblock_l_schema():
|
|||
with pytest.raises(ValueError):
|
||||
schema = img.__arrow_c_schema__()
|
||||
|
||||
|
||||
def test_multiblock_rgba_schema():
|
||||
block_size = Image.core.get_block_size()
|
||||
|
||||
|
@ -199,7 +201,7 @@ def test_multiblock_rgba_schema():
|
|||
img = Image.new("RGBA", size, (128, 127, 126, 125))
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
schema= img.__arrow_c_schema__()
|
||||
schema = img.__arrow_c_schema__()
|
||||
|
||||
|
||||
def test_singleblock_l_image():
|
||||
|
@ -208,8 +210,8 @@ def test_singleblock_l_image():
|
|||
block_size = Image.core.get_block_size()
|
||||
|
||||
# check a 2 block image in 4 channel mode
|
||||
size = (4096, 2* (block_size//4096))
|
||||
img = Image.new('L', size, 128)
|
||||
size = (4096, 2 * (block_size // 4096))
|
||||
img = Image.new("L", size, 128)
|
||||
assert img.im.isblock()
|
||||
|
||||
(schema, arr) = img.__arrow_c_array__()
|
||||
|
@ -218,13 +220,14 @@ def test_singleblock_l_image():
|
|||
|
||||
Image.core.set_use_block_allocator(0)
|
||||
|
||||
|
||||
def test_singleblock_rgba_image():
|
||||
Image.core.set_use_block_allocator(1)
|
||||
block_size = Image.core.get_block_size()
|
||||
|
||||
# check a 2 block image in 4 channel mode
|
||||
size = (4096, (block_size//4096) //2)
|
||||
img = Image.new('RGBA', size, (128,127,126,125))
|
||||
size = (4096, (block_size // 4096) // 2)
|
||||
img = Image.new("RGBA", size, (128, 127, 126, 125))
|
||||
assert img.im.isblock()
|
||||
|
||||
(schema, arr) = img.__arrow_c_array__()
|
||||
|
@ -238,23 +241,24 @@ def test_singleblock_l_schema():
|
|||
block_size = Image.core.get_block_size()
|
||||
|
||||
# check a 2 block image in single channel mode
|
||||
size = (4096, 2*block_size//4096)
|
||||
img = Image.new('L', size, 128)
|
||||
size = (4096, 2 * block_size // 4096)
|
||||
img = Image.new("L", size, 128)
|
||||
assert img.im.isblock()
|
||||
|
||||
schema = img.__arrow_c_schema__()
|
||||
assert schema
|
||||
Image.core.set_use_block_allocator(0)
|
||||
|
||||
|
||||
def test_singleblock_rgba_schema():
|
||||
Image.core.set_use_block_allocator(1)
|
||||
block_size = Image.core.get_block_size()
|
||||
|
||||
# check a 2 block image in 4 channel mode
|
||||
size = (4096, (block_size//4096) //2)
|
||||
img = Image.new('RGBA', size, (128,127,126,125))
|
||||
size = (4096, (block_size // 4096) // 2)
|
||||
img = Image.new("RGBA", size, (128, 127, 126, 125))
|
||||
assert img.im.isblock()
|
||||
|
||||
schema= img.__arrow_c_schema__()
|
||||
schema = img.__arrow_c_schema__()
|
||||
assert schema
|
||||
Image.core.set_use_block_allocator(0)
|
||||
|
|
|
@ -302,7 +302,9 @@ _new_arrow(PyObject *self, PyObject *args) {
|
|||
}
|
||||
|
||||
// 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) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
_get_use_block_allocator(PyObject *self, PyObject *args) {
|
||||
return PyLong_FromLong(ImagingDefaultArena.use_block_allocator);
|
||||
|
|
|
@ -379,7 +379,6 @@ ImagingMemorySetBlockAllocator(ImagingMemoryArena arena, int use_block_allocator
|
|||
arena->use_block_allocator = use_block_allocator;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImagingMemoryClearCache(ImagingMemoryArena arena, int new_size) {
|
||||
while (arena->blocks_cached > new_size) {
|
||||
|
@ -574,14 +573,19 @@ ImagingAllocateBlock(Imaging im) {
|
|||
static void
|
||||
ImagingDestroyArrow(Imaging im) {
|
||||
// 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);
|
||||
im->arrow_array_capsule = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
Py_ssize_t y, i;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user