Skip to content

Commit a96b016

Browse files
author
Diptorup Deb
committed
Fix cython flake issues
1 parent 05a9671 commit a96b016

File tree

9 files changed

+322
-227
lines changed

9 files changed

+322
-227
lines changed

dpctl/_sycl_context.pyx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import logging
2727
from cpython cimport pycapsule
2828
from cpython.mem cimport PyMem_Free, PyMem_Malloc
2929

30-
from ._backend cimport (
30+
from ._backend cimport ( # noqa: E211
3131
DPCTLContext_AreEq,
3232
DPCTLContext_Copy,
3333
DPCTLContext_Create,
@@ -59,7 +59,9 @@ _logger = logging.getLogger(__name__)
5959
cdef void _context_capsule_deleter(object o):
6060
cdef DPCTLSyclContextRef CRef = NULL
6161
if pycapsule.PyCapsule_IsValid(o, "SyclContextRef"):
62-
CRef = <DPCTLSyclContextRef> pycapsule.PyCapsule_GetPointer(o, "SyclContextRef")
62+
CRef = <DPCTLSyclContextRef> pycapsule.PyCapsule_GetPointer(
63+
o, "SyclContextRef"
64+
)
6365
DPCTLContext_Delete(CRef)
6466

6567

@@ -127,7 +129,7 @@ cdef class SyclContext(_SyclContext):
127129
128130
# Create a CPU device using the opencl driver
129131
cpu_d = dpctl.SyclDevice("opencl:cpu")
130-
# Partition the CPU device into sub-devices, each with two cores.
132+
# Partition the CPU device into sub-devices with two cores each.
131133
sub_devices = cpu_d.create_sub_devices(partition=2)
132134
# Create a context common to all the sub-devices.
133135
ctx = dpctl.SyclContext(sub_devices)
@@ -157,7 +159,7 @@ cdef class SyclContext(_SyclContext):
157159

158160
@staticmethod
159161
cdef void _init_helper(_SyclContext context, DPCTLSyclContextRef CRef):
160-
context._ctxt_ref = CRef
162+
context._ctxt_ref = CRef
161163

162164
@staticmethod
163165
cdef SyclContext _create(DPCTLSyclContextRef ctxt):
@@ -257,8 +259,8 @@ cdef class SyclContext(_SyclContext):
257259
return 0
258260
else:
259261
# __cinit__ checks that capsule is valid, so one can be here only
260-
# if call to `_init_context_from_capsule` was made outside of __cinit__
261-
# and the capsule was not checked to be valid
262+
# if call to `_init_context_from_capsule` was made outside of
263+
# __cinit__ and the capsule was not checked to be valid
262264
return -128
263265

264266
def __cinit__(self, arg=None):
@@ -269,8 +271,8 @@ cdef class SyclContext(_SyclContext):
269271
ret = self._init_context_from_one_device(<SyclDevice> arg, 0)
270272
elif pycapsule.PyCapsule_IsValid(arg, "SyclContextRef"):
271273
status = self._init_context_from_capsule(arg)
272-
elif isinstance(
273-
arg, (list, tuple)) and all([isinstance(argi, SyclDevice) for argi in arg]
274+
elif isinstance(arg, (list, tuple)) and all(
275+
[isinstance(argi, SyclDevice) for argi in arg]
274276
):
275277
ret = self._init_context_from_devices(arg, 0)
276278
else:
@@ -336,7 +338,7 @@ cdef class SyclContext(_SyclContext):
336338
cdef DPCTLSyclContextRef get_context_ref(self):
337339
return self._ctxt_ref
338340

339-
def addressof_ref (self):
341+
def addressof_ref(self):
340342
"""
341343
Returns the address of the ``DPCTLSyclContextRef`` pointer as a
342344
``size_t``.
@@ -419,7 +421,8 @@ cdef class SyclContext(_SyclContext):
419421
cpu_d = dpctl.SyclDevice("opencl:cpu")
420422
sub_devices = create_sub_devices(partition=2)
421423
ctx2 = dpctl.SyclContext(sub_devices)
422-
print(ctx2) # E.g : <dpctl.SyclContext for 4 devices at 0x7f154d8ab070>
424+
# prints: <dpctl.SyclContext for 4 devices at 0x7f154d8ab070>
425+
print(ctx2)
423426
424427
Returns:
425428
:obj:`str`: A string representation of the

0 commit comments

Comments
 (0)