Skip to content

Commit be3b0fd

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 2401757 commit be3b0fd

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

Tests/test_arrow.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def test_multiblock_l_image():
170170
with pytest.raises(ValueError):
171171
(schema, arr) = img.__arrow_c_array__()
172172

173+
173174
def test_multiblock_rgba_image():
174175
block_size = Image.core.get_block_size()
175176

@@ -191,6 +192,7 @@ def test_multiblock_l_schema():
191192
with pytest.raises(ValueError):
192193
schema = img.__arrow_c_schema__()
193194

195+
194196
def test_multiblock_rgba_schema():
195197
block_size = Image.core.get_block_size()
196198

@@ -199,7 +201,7 @@ def test_multiblock_rgba_schema():
199201
img = Image.new("RGBA", size, (128, 127, 126, 125))
200202

201203
with pytest.raises(ValueError):
202-
schema= img.__arrow_c_schema__()
204+
schema = img.__arrow_c_schema__()
203205

204206

205207
def test_singleblock_l_image():
@@ -208,8 +210,8 @@ def test_singleblock_l_image():
208210
block_size = Image.core.get_block_size()
209211

210212
# check a 2 block image in 4 channel mode
211-
size = (4096, 2* (block_size//4096))
212-
img = Image.new('L', size, 128)
213+
size = (4096, 2 * (block_size // 4096))
214+
img = Image.new("L", size, 128)
213215
assert img.im.isblock()
214216

215217
(schema, arr) = img.__arrow_c_array__()
@@ -218,13 +220,14 @@ def test_singleblock_l_image():
218220

219221
Image.core.set_use_block_allocator(0)
220222

223+
221224
def test_singleblock_rgba_image():
222225
Image.core.set_use_block_allocator(1)
223226
block_size = Image.core.get_block_size()
224227

225228
# check a 2 block image in 4 channel mode
226-
size = (4096, (block_size//4096) //2)
227-
img = Image.new('RGBA', size, (128,127,126,125))
229+
size = (4096, (block_size // 4096) // 2)
230+
img = Image.new("RGBA", size, (128, 127, 126, 125))
228231
assert img.im.isblock()
229232

230233
(schema, arr) = img.__arrow_c_array__()
@@ -238,23 +241,24 @@ def test_singleblock_l_schema():
238241
block_size = Image.core.get_block_size()
239242

240243
# check a 2 block image in single channel mode
241-
size = (4096, 2*block_size//4096)
242-
img = Image.new('L', size, 128)
244+
size = (4096, 2 * block_size // 4096)
245+
img = Image.new("L", size, 128)
243246
assert img.im.isblock()
244247

245248
schema = img.__arrow_c_schema__()
246249
assert schema
247250
Image.core.set_use_block_allocator(0)
248251

252+
249253
def test_singleblock_rgba_schema():
250254
Image.core.set_use_block_allocator(1)
251255
block_size = Image.core.get_block_size()
252256

253257
# check a 2 block image in 4 channel mode
254-
size = (4096, (block_size//4096) //2)
255-
img = Image.new('RGBA', size, (128,127,126,125))
258+
size = (4096, (block_size // 4096) // 2)
259+
img = Image.new("RGBA", size, (128, 127, 126, 125))
256260
assert img.im.isblock()
257261

258-
schema= img.__arrow_c_schema__()
262+
schema = img.__arrow_c_schema__()
259263
assert schema
260264
Image.core.set_use_block_allocator(0)

src/_imaging.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ _new_arrow(PyObject *self, PyObject *args) {
302302
}
303303

304304
// ImagingBorrowArrow is responsible for retaining the array_capsule
305-
ret = PyImagingNew(ImagingNewArrow(mode, xsize, ysize, schema_capsule, array_capsule));
305+
ret =
306+
PyImagingNew(ImagingNewArrow(mode, xsize, ysize, schema_capsule, array_capsule)
307+
);
306308
if (!ret) {
307309
return ImagingError_ValueError("Invalid arrow array mode or size mismatch");
308310
}
@@ -4202,7 +4204,6 @@ _set_use_block_allocator(PyObject *self, PyObject *args) {
42024204
Py_RETURN_NONE;
42034205
}
42044206

4205-
42064207
static PyObject *
42074208
_get_use_block_allocator(PyObject *self, PyObject *args) {
42084209
return PyLong_FromLong(ImagingDefaultArena.use_block_allocator);

src/libImaging/Storage.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ ImagingMemorySetBlockAllocator(ImagingMemoryArena arena, int use_block_allocator
379379
arena->use_block_allocator = use_block_allocator;
380380
}
381381

382-
383382
void
384383
ImagingMemoryClearCache(ImagingMemoryArena arena, int new_size) {
385384
while (arena->blocks_cached > new_size) {
@@ -574,14 +573,19 @@ ImagingAllocateBlock(Imaging im) {
574573
static void
575574
ImagingDestroyArrow(Imaging im) {
576575
// Rely on the internal python destructor for the array capsule.
577-
if (im->arrow_array_capsule){
576+
if (im->arrow_array_capsule) {
578577
Py_DECREF(im->arrow_array_capsule);
579578
im->arrow_array_capsule = NULL;
580579
}
581580
}
582581

583582
Imaging
584-
ImagingBorrowArrow(Imaging im, struct ArrowArray *external_array, int offset_width, PyObject* arrow_capsule) {
583+
ImagingBorrowArrow(
584+
Imaging im,
585+
struct ArrowArray *external_array,
586+
int offset_width,
587+
PyObject *arrow_capsule
588+
) {
585589
// offset_width is the # of char* for a single offset from arrow
586590
Py_ssize_t y, i;
587591

0 commit comments

Comments
 (0)