mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-17 03:23:12 +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):
|
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()
|
||||||
|
|
||||||
|
@ -199,7 +201,7 @@ def test_multiblock_rgba_schema():
|
||||||
img = Image.new("RGBA", size, (128, 127, 126, 125))
|
img = Image.new("RGBA", size, (128, 127, 126, 125))
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
schema= img.__arrow_c_schema__()
|
schema = img.__arrow_c_schema__()
|
||||||
|
|
||||||
|
|
||||||
def test_singleblock_l_image():
|
def test_singleblock_l_image():
|
||||||
|
@ -208,8 +210,8 @@ def test_singleblock_l_image():
|
||||||
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, 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__()
|
||||||
|
@ -238,23 +241,24 @@ def test_singleblock_l_schema():
|
||||||
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
|
||||||
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__()
|
||||||
assert schema
|
assert schema
|
||||||
Image.core.set_use_block_allocator(0)
|
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
|
// 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);
|
||||||
|
|
|
@ -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) {
|
||||||
|
@ -574,14 +573,19 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user