Skip to content

Commit

Permalink
ruff: fix E265 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl committed Aug 11, 2024
1 parent 7bb4a68 commit 7546235
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 31 deletions.
6 changes: 3 additions & 3 deletions contrib/fortran-to-opencl/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,8 +1204,8 @@ def map_Save(self, node):
raise NotImplementedError("save")

def map_Line(self, node):
#from warnings import warn
#warn("Encountered a 'line': %s" % node)
# from warnings import warn
# warn("Encountered a 'line': %s" % node)
raise NotImplementedError

def map_Program(self, node):
Expand Down Expand Up @@ -1390,7 +1390,7 @@ def f2cl(source, free_form=False, strict=True,

mod = cgen.Module([*func_decls, cgen.Line(), *source])

#open("pre-cnd.cl", "w").write(str(mod))
# open("pre-cnd.cl", "w").write(str(mod))

from cnd import transform_cl
str_mod = transform_cl(str(mod))
Expand Down
2 changes: 1 addition & 1 deletion doc/make_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def get_extra_lines(tup):
}

cls_ext_lookup = {
#cl.buffer_create_type: ("CL_1.1", "0.92"),
# cl.buffer_create_type: ("CL_1.1", "0.92"),
}


Expand Down
4 changes: 2 additions & 2 deletions examples/dump-properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def print_info(obj, info_cls):
ctx = cl.Context([device])
for mf in [
cl.mem_flags.READ_ONLY,
#cl.mem_flags.READ_WRITE,
#cl.mem_flags.WRITE_ONLY
# cl.mem_flags.READ_WRITE,
# cl.mem_flags.WRITE_ONLY
]:
for itype in [
cl.mem_object_type.IMAGE2D,
Expand Down
4 changes: 2 additions & 2 deletions pyopencl/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def _splay(device, n, kernel_specific_max_wg_size=None):
group_count = max_groups
work_items_per_group = max_work_items

#print "n:%d gc:%d wipg:%d" % (n, group_count, work_items_per_group)
# print("n:%d gc:%d wipg:%d" % (n, group_count, work_items_per_group))
return (group_count*work_items_per_group,), (work_items_per_group,)


Expand Down Expand Up @@ -590,7 +590,7 @@ def __init__(
# FIXME It would be nice to check this. But it would require
# changing the allocator interface. Trust the user for now.

#assert allocator.context == context
# assert allocator.context == context
pass

# Queue-less arrays do have a purpose in life.
Expand Down
2 changes: 1 addition & 1 deletion pyopencl/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def first_arg_dependent_memoize_nested(nested_func):
cache_context = caller_frame.f_globals[
caller_frame.f_code.co_name]
finally:
#del caller_frame
# del caller_frame
pass

try:
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ extend-ignore = [
"C409", # remove comprehension within tuple call
"E226", # missing whitespace around arithmetic operator
"E241", # multiple spaces after comma
"E242", # tab after comma
"E265", # block comment should start with #
"E402", # module level import not at the top of file
"C90", # McCabe complexity
"UP031", # use f-strings instead of %
Expand Down
14 changes: 7 additions & 7 deletions test/test_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ def test_struct_reduce(ctx_factory):
arguments="__global int *x", preamble=preamble)

minmax = red(a_gpu).get()
#print minmax["cur_min"], minmax["cur_max"]
#print np.min(a), np.max(a)
# print(minmax["cur_min"], minmax["cur_max"])
# print(np.min(a), np.max(a))

assert abs(minmax["cur_min"] - np.min(a)) < 1e-5
assert abs(minmax["cur_max"] - np.max(a)) < 1e-5
Expand Down Expand Up @@ -756,7 +756,7 @@ def test_segmented_scan(ctx_factory):
dtype = np.int32
ctype = dtype_to_ctype(dtype)

#for is_exclusive in [False, True]:
# for is_exclusive in [False, True]:
for is_exclusive in [True, False]:
if is_exclusive:
output_statement = "out[i] = prev_item"
Expand Down Expand Up @@ -798,8 +798,8 @@ def test_segmented_scan(ctx_factory):
seg_boundaries_values.append(seg_boundaries)

for seg_boundaries in seg_boundaries_values:
#print "BOUNDARIES", seg_boundaries
#print a
# print("BOUNDARIES", seg_boundaries)
# print(a)

seg_boundary_flags = np.zeros(n, dtype=np.uint8)
seg_boundary_flags[seg_boundaries] = 1
Expand All @@ -823,12 +823,12 @@ def test_segmented_scan(ctx_factory):
result_host[seg_start:seg_end] = np.cumsum(
a[seg_start:seg_end])

#print "REF", result_host
# print("REF", result_host)

result_dev = cl.array.empty_like(a_dev)
knl(a_dev, seg_boundary_flags_dev, result_dev)

#print "RES", result_dev
# print("RES", result_dev)
is_correct = (result_dev.get() == result_host).all()
if not is_correct:
diff = result_dev.get() - result_host
Expand Down
20 changes: 10 additions & 10 deletions test/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_mix_complex(ctx_factory):

dtypes = [
(np.float32, np.complex64),
#(np.int32, np.complex64),
# (np.int32, np.complex64),
]

dev = context.devices[0]
Expand Down Expand Up @@ -389,8 +389,8 @@ def test_custom_type_take_put(ctx_factory):
# {{{ test_div_type_matches_numpy

@pytest.mark.parametrize("dtype", [np.int8, np.int32, np.int64, np.float32])
# FIXME Implement florodiv
#@pytest.mark.parametrize("op", [operator.truediv, operator.floordiv])
# FIXME Implement floordiv
# @pytest.mark.parametrize("op", [operator.truediv, operator.floordiv])
@pytest.mark.parametrize("op", [operator.truediv])
def test_div_type_matches_numpy(ctx_factory, dtype, op):
context = ctx_factory()
Expand Down Expand Up @@ -547,7 +547,7 @@ def test_addition_scalar(ctx_factory):
])
def test_subtract_array(ctx_factory, dtype_a, dtype_b):
"""Test the subtraction of two arrays."""
#test data
# test data
a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).astype(dtype_a)
b = np.array([10, 20, 30, 40, 50,
60, 70, 80, 90, 100]).astype(dtype_b)
Expand Down Expand Up @@ -575,10 +575,10 @@ def test_subtract_scalar(ctx_factory):
context = ctx_factory()
queue = cl.CommandQueue(context)

#test data
# test data
a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).astype(np.float32)

#convert a to a gpu object
# convert a to a gpu object
a_gpu = cl_array.to_device(queue, a)

result = (a_gpu - 7).get()
Expand Down Expand Up @@ -1166,7 +1166,7 @@ def test_slice(ctx_factory):

for _i in range(20):
start = randrange(ary_len-start_offset)
#end = randrange(start+start_offset, ary_len)
# end = randrange(start+start_offset, ary_len)
end = start

a_gpu[start:end] = tp(2)*b[start:end]
Expand Down Expand Up @@ -1466,7 +1466,7 @@ def test_transpose(ctx_factory):
a = a_gpu.get()

# FIXME: not contiguous
#assert np.allclose(a_gpu.transpose((1,2,0)).get(), a.transpose((1,2,0)))
# assert np.allclose(a_gpu.transpose((1,2,0)).get(), a.transpose((1,2,0)))
assert np.array_equal(a_gpu.T.get(), a.T)

# }}}
Expand Down Expand Up @@ -1516,7 +1516,7 @@ def test_squeeze(ctx_factory):
assert a_gpu_squeezed_slice.flags.c_contiguous

# Check that we get the original values out
#assert np.all(a_gpu_slice.get().ravel() == a_gpu_squeezed_slice.get().ravel())
# assert np.all(a_gpu_slice.get().ravel() == a_gpu_squeezed_slice.get().ravel())

# Slice with length 1 on dimensions 2
a_gpu_slice = a_gpu[:, :, 2:3, :]
Expand All @@ -1529,7 +1529,7 @@ def test_squeeze(ctx_factory):
assert not a_gpu_squeezed_slice.flags.c_contiguous

# Check that we get the original values out
#assert np.all(a_gpu_slice.get().ravel() == a_gpu_squeezed_slice.get().ravel())
# assert np.all(a_gpu_slice.get().ravel() == a_gpu_squeezed_slice.get().ravel())

# }}}

Expand Down
4 changes: 2 additions & 2 deletions test/test_clmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ def get_err(check, ref):
if 0 and n == 15:
import matplotlib.pyplot as pt

#pt.plot(scipy_bessel)
#pt.plot(cl_bessel)
# pt.plot(scipy_bessel)
# pt.plot(cl_bessel)

pt.loglog(a, np.abs(cl_bessel-scipy_bessel), label="vs scipy")
if use_pyfmmlib:
Expand Down
2 changes: 1 addition & 1 deletion test/test_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def test_image_2d(ctx_factory):
# {{{ test_image_3d

def test_image_3d(ctx_factory):
#test for image_from_array for 3d image of float2
# test for image_from_array for 3d image of float2
context = ctx_factory()

device, = context.devices
Expand Down

0 comments on commit 7546235

Please sign in to comment.