[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 15:29:27 +00:00
parent e7bd152aac
commit 9f94d4f9f8
5 changed files with 39 additions and 40 deletions

View File

@ -159,22 +159,24 @@ def test_readonly():
reloaded._readonly = 0 reloaded._readonly = 0
assert reloaded.readonly == 1 assert reloaded.readonly == 1
def test_multiblock_l_image(): def test_multiblock_l_image():
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)
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()
# 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))
with pytest.raises(ValueError): with pytest.raises(ValueError):
(schema, arr) = img.__arrow_c_array__() (schema, arr) = img.__arrow_c_array__()
@ -185,17 +187,18 @@ def test_multiblock_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)
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()
# 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))
with pytest.raises(ValueError): with pytest.raises(ValueError):
schema = img.__arrow_c_schema__() schema = img.__arrow_c_schema__()

View File

@ -236,7 +236,9 @@ ArrowError(int err) {
return ImagingError_ValueError("Incompatible Pillow mode for Arrow Array"); return ImagingError_ValueError("Incompatible Pillow mode for Arrow Array");
} }
if (err == IMAGING_ARROW_MEMORY_LAYOUT) { if (err == IMAGING_ARROW_MEMORY_LAYOUT) {
return ImagingError_ValueError("Image is in multiple array blocks, use imaging_new_block for zero copy"); return ImagingError_ValueError(
"Image is in multiple array blocks, use imaging_new_block for zero copy"
);
} }
return ImagingError_ValueError("Unknown Error"); return ImagingError_ValueError("Unknown Error");
} }
@ -286,7 +288,6 @@ ExportArrowArrayPyCapsule(ImagingObject *self) {
return ArrowError(err); return ArrowError(err);
} }
static PyObject * static PyObject *
_new_arrow(PyObject *self, PyObject *args) { _new_arrow(PyObject *self, PyObject *args) {
char *mode; char *mode;

View File

@ -123,8 +123,6 @@ export_imaging_schema(Imaging im, struct ArrowSchema *schema) {
return 0; return 0;
} }
static void static void
release_const_array(struct ArrowArray *array) { release_const_array(struct ArrowArray *array) {
Imaging im = (Imaging)array->private_data; Imaging im = (Imaging)array->private_data;

View File

@ -121,8 +121,6 @@ struct ImagingMemoryInstance {
#ifdef Py_GIL_DISABLED #ifdef Py_GIL_DISABLED
PyMutex mutex; PyMutex mutex;
#endif #endif
}; };
#define IMAGING_PIXEL_1(im, x, y) ((im)->image8[(y)][(x)]) #define IMAGING_PIXEL_1(im, x, y) ((im)->image8[(y)][(x)])
@ -747,7 +745,6 @@ export_imaging_schema(Imaging im, struct ArrowSchema *schema);
#define IMAGING_ARROW_INCOMPATIBLE_MODE -10 #define IMAGING_ARROW_INCOMPATIBLE_MODE -10
#define IMAGING_ARROW_MEMORY_LAYOUT -11 #define IMAGING_ARROW_MEMORY_LAYOUT -11
#include "ImagingUtils.h" #include "ImagingUtils.h"
extern UINT8 *clip8_lookups; extern UINT8 *clip8_lookups;