Skip to content

Commit f0c8749

Browse files
author
Diptorup Deb
committed
Fix issues found by flake8 in dpctl and its submodules.
1 parent ee86a33 commit f0c8749

19 files changed

+508
-331
lines changed

dpctl/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
2020
Dpctl's Python API implements Python wrappers for a subset of DPC++/SYCL's
2121
API. The Python API exposes wrappers for the SYCL runtime classes (expect
22-
`device_selector`) described in Section 4.6 of the SYCL 2020 spec (https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#_sycl_runtime_classes).
23-
Apart from the main SYCL runtime classes, dpctl includes a `memory` sub-module that exposes the SYCL USM allocators and deallocators.
22+
``device_selector``) described in Section 4.6 of the
23+
[SYCL 2020 spec](https://www.khronos.org/registry/SYCL/specs/sycl-2020/
24+
html/sycl-2020.html#_sycl_runtime_classes).
25+
Apart from the main SYCL runtime classes, dpctl includes a `memory`
26+
sub-module that exposes the SYCL USM allocators and deallocators.
2427
"""
2528
__author__ = "Intel Corp."
2629

@@ -56,8 +59,8 @@
5659

5760

5861
def get_include():
59-
r"""
60-
Return the directory that contains the dpctl \*.h header files.
62+
"""
63+
Return the directory that contains the dpctl *.h header files.
6164
6265
Extension modules that need to be compiled against dpctl should use
6366
this function to locate the appropriate include directory.

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)