Skip to content

Commit ae6817d

Browse files
committed
lint: First pass with ruff --fix
1 parent 43a044d commit ae6817d

164 files changed

Lines changed: 1523 additions & 1209 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmarks/user/advisor/roofline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def roofline(name, project, scale, precision, mode, th):
128128
# y = bandwidth * x
129129
x1, x2 = 0, min(width, max_compute_bandwidth / bandwidth)
130130
y1, y2 = 0, x2*bandwidth
131-
label = '{} {:.0f} GB/s'.format(roof.name, bandwidth)
131+
label = f'{roof.name} {bandwidth:.0f} GB/s'
132132
ax.plot([x1, x2], [y1, y2], '-', label=label)
133133
memory_roofs.append(((x1, x2), (y1, y2)))
134134

@@ -138,7 +138,7 @@ def roofline(name, project, scale, precision, mode, th):
138138
bandwidth /= scale # scale down as requested by the user
139139
x1, x2 = max(bandwidth / max_memory_bandwidth, 0), width
140140
y1, y2 = bandwidth, bandwidth
141-
label = '{} {:.0f} GFLOPS'.format(roof.name, bandwidth)
141+
label = f'{roof.name} {bandwidth:.0f} GFLOPS'
142142
ax.plot([x1, x2], [y1, y2], '-', label=label)
143143
compute_roofs.append(((x1, x2), (y1, y2)))
144144

benchmarks/user/benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def run(problem, **kwargs):
274274
# Note: the following piece of code is horribly *hacky*, but it works for now
275275
for i, block_shape in enumerate(block_shapes):
276276
for n, level in enumerate(block_shape):
277-
for d, s in zip(['x', 'y', 'z'], level):
277+
for d, s in zip(['x', 'y', 'z'], level, strict=False):
278278
options['%s%d_blk%d_size' % (d, i, n)] = s
279279

280280
solver = setup(space_order=space_order, time_order=time_order, **kwargs)

devito/arch/archinfo.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def get_cpu_info():
4848

4949
# Obtain textual cpu info
5050
try:
51-
with open('/proc/cpuinfo', 'r') as f:
51+
with open('/proc/cpuinfo') as f:
5252
lines = f.readlines()
5353
except FileNotFoundError:
5454
lines = []
@@ -696,9 +696,7 @@ def get_platform():
696696
elif 'intel' in brand:
697697
# Most likely a desktop i3/i5/i7
698698
return platform_registry['intel64']
699-
elif 'power8' in brand:
700-
return platform_registry['power8']
701-
elif 'power9' in brand:
699+
elif 'power8' in brand or 'power9' in brand:
702700
return platform_registry['power8']
703701
elif 'arm' in brand:
704702
return platform_registry['arm']

devito/arch/compiler.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
as_list, change_directory, filter_ordered, make_tempdir, memoized_func
2424
)
2525

26-
__all__ = ['sniff_mpi_distro', 'compiler_registry']
26+
__all__ = ['compiler_registry', 'sniff_mpi_distro']
2727

2828

2929
@memoized_func
@@ -51,11 +51,7 @@ def sniff_compiler_version(cc, allow_fail=False):
5151
ver = ver.strip()
5252
if ver.startswith("gcc"):
5353
compiler = "gcc"
54-
elif ver.startswith("clang"):
55-
compiler = "clang"
56-
elif ver.startswith("Apple LLVM"):
57-
compiler = "clang"
58-
elif ver.startswith("Homebrew clang"):
54+
elif ver.startswith("clang") or ver.startswith("Apple LLVM") or ver.startswith("Homebrew clang"):
5955
compiler = "clang"
6056
elif ver.startswith("Intel"):
6157
compiler = "icx"
@@ -388,7 +384,7 @@ def jit_compile(self, soname, code):
388384
# Warning: dropping `code` on the floor in favor to whatever is written
389385
# within `src_file`
390386
try:
391-
with open(src_file, 'r') as f:
387+
with open(src_file) as f:
392388
code = f.read()
393389
code = f'{code}/* Backdoor edit at {time.ctime()}*/ \n'
394390
# Bypass the devito JIT cache

devito/builtins/arithmetic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import devito as dv
44
from devito.builtins.utils import check_builtins_args, make_retval
55

6-
__all__ = ['norm', 'sumall', 'sum', 'inner', 'mmin', 'mmax']
6+
__all__ = ['inner', 'mmax', 'mmin', 'norm', 'sum', 'sumall']
77

88

99
@dv.switchconfig(log_level='ERROR')

devito/builtins/initializers.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from devito.builtins.utils import check_builtins_args, nbl_to_padsize, pad_outhalo
55
from devito.tools import as_list, as_tuple
66

7-
__all__ = ['assign', 'smooth', 'gaussian_smooth', 'initialize_function']
7+
__all__ = ['assign', 'gaussian_smooth', 'initialize_function', 'smooth']
88

99

1010
@dv.switchconfig(log_level='ERROR')
@@ -59,18 +59,18 @@ def assign(f, rhs=0, options=None, name='assign', assign_halo=False, **kwargs):
5959

6060
eqs = []
6161
if options:
62-
for i, j, k in zip(as_list(f), rhs, options):
62+
for i, j, k in zip(as_list(f), rhs, options, strict=False):
6363
if k is not None:
6464
eqs.append(dv.Eq(i, j, **k))
6565
else:
6666
eqs.append(dv.Eq(i, j))
6767
else:
68-
for i, j in zip(as_list(f), rhs):
68+
for i, j in zip(as_list(f), rhs, strict=False):
6969
eqs.append(dv.Eq(i, j))
7070

7171
if assign_halo:
7272
subs = {}
73-
for d, h in zip(f.dimensions, f._size_halo):
73+
for d, h in zip(f.dimensions, f._size_halo, strict=False):
7474
if sum(h) == 0:
7575
continue
7676
subs[d] = dv.CustomDimension(name=d.name, parent=d,
@@ -143,15 +143,15 @@ def __init__(self, lw):
143143
self.lw = lw
144144

145145
def define(self, dimensions):
146-
return {d: ('middle', l, l) for d, l in zip(dimensions, self.lw)}
146+
return {d: ('middle', l, l) for d, l in zip(dimensions, self.lw, strict=False)}
147147

148148
def create_gaussian_weights(sigma, lw):
149149
weights = [w/w.sum() for w in (np.exp(-0.5/s**2*(np.linspace(-l, l, 2*l+1))**2)
150-
for s, l in zip(sigma, lw))]
150+
for s, l in zip(sigma, lw, strict=False))]
151151
return as_tuple(np.array(w) for w in weights)
152152

153153
def fset(f, g):
154-
indices = [slice(l, -l, 1) for _, l in zip(g.dimensions, lw)]
154+
indices = [slice(l, -l, 1) for _, l in zip(g.dimensions, lw, strict=False)]
155155
slices = (slice(None, None, 1), )*g.ndim
156156
if isinstance(f, np.ndarray):
157157
f[slices] = g.data[tuple(indices)]
@@ -182,7 +182,7 @@ def fset(f, g):
182182

183183
# Create the padded grid:
184184
objective_domain = ObjectiveDomain(lw)
185-
shape_padded = tuple([np.array(s) + 2*l for s, l in zip(shape, lw)])
185+
shape_padded = tuple([np.array(s) + 2*l for s, l in zip(shape, lw, strict=False)])
186186
extent_padded = tuple([s-1 for s in shape_padded])
187187
grid = dv.Grid(shape=shape_padded, subdomains=objective_domain,
188188
extent=extent_padded)
@@ -193,7 +193,7 @@ def fset(f, g):
193193
weights = create_gaussian_weights(sigma, lw)
194194

195195
mapper = {}
196-
for d, l, w in zip(f_c.dimensions, lw, weights):
196+
for d, l, w in zip(f_c.dimensions, lw, weights, strict=False):
197197
lhs = []
198198
rhs = []
199199
options = []
@@ -238,11 +238,11 @@ def _initialize_function(function, data, nbl, mapper=None, mode='constant'):
238238
def buff(i, j):
239239
return [(i + k - 2*max(max(nbl))) for k in j]
240240

241-
b = [min(l) for l in (w for w in (buff(i, j) for i, j in zip(local_size, halo)))]
241+
b = [min(l) for l in (w for w in (buff(i, j) for i, j in zip(local_size, halo, strict=False)))]
242242
if any(np.array(b) < 0):
243243
raise ValueError("Function `%s` halo is not sufficiently thick." % function)
244244

245-
for d, (nl, nr) in zip(function.space_dimensions, as_tuple(nbl)):
245+
for d, (nl, nr) in zip(function.space_dimensions, as_tuple(nbl), strict=False):
246246
dim_l = dv.SubDimension.left(name='abc_%s_l' % d.name, parent=d, thickness=nl)
247247
dim_r = dv.SubDimension.right(name='abc_%s_r' % d.name, parent=d, thickness=nr)
248248
if mode == 'constant':
@@ -373,14 +373,14 @@ def initialize_function(function, data, nbl, mapper=None, mode='constant',
373373
f._create_data()
374374

375375
if nbl == 0:
376-
for f, data in zip(functions, datas):
376+
for f, data in zip(functions, datas, strict=False):
377377
if isinstance(data, dv.Function):
378378
f.data[:] = data.data[:]
379379
else:
380380
f.data[:] = data[:]
381381
else:
382382
lhss, rhss, optionss = [], [], []
383-
for f, data in zip(functions, datas):
383+
for f, data in zip(functions, datas, strict=False):
384384

385385
lhs, rhs, options = _initialize_function(f, data, nbl, mapper, mode)
386386

devito/builtins/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
from devito.symbolics import uxreplace
88
from devito.tools import as_tuple
99

10-
__all__ = ['make_retval', 'nbl_to_padsize', 'pad_outhalo', 'abstract_args',
11-
'check_builtins_args']
10+
__all__ = [
11+
'abstract_args',
12+
'check_builtins_args',
13+
'make_retval',
14+
'nbl_to_padsize',
15+
'pad_outhalo',
16+
]
1217

1318

1419
accumulator_mapper = {

devito/core/arm.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
from devito.core.cpu import Cpu64AdvCOperator, Cpu64AdvCXXOperator, Cpu64AdvOperator
22
from devito.passes.iet import CXXOmpTarget, OmpTarget
33

4-
__all__ = ['ArmAdvCOperator', 'ArmAdvOmpOperator', 'ArmAdvCXXOperator',
5-
'ArmAdvCXXOmpOperator']
4+
__all__ = [
5+
'ArmAdvCOperator',
6+
'ArmAdvCXXOmpOperator',
7+
'ArmAdvCXXOperator',
8+
'ArmAdvOmpOperator',
9+
]
610

711

812
ArmAdvOperator = Cpu64AdvOperator

devito/core/autotuning.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ def calculate_nblocks(tree, blockable):
271271
collapsed = tree[index:index + (ncollapsed or index+1)]
272272
blocked = [i.dim for i in collapsed if i.dim in blockable]
273273
remainders = [(d.root.symbolic_max-d.root.symbolic_min+1) % d.step for d in blocked]
274-
niters = [d.root.symbolic_max - i for d, i in zip(blocked, remainders)]
274+
niters = [d.root.symbolic_max - i for d, i in zip(blocked, remainders, strict=False)]
275275
nblocks = prod((i - d.root.symbolic_min + 1) / d.step
276-
for d, i in zip(blocked, niters))
276+
for d, i in zip(blocked, niters, strict=False))
277277
return nblocks
278278

279279

@@ -324,7 +324,7 @@ def generate_block_shapes(blockable, args, level):
324324
level_1 = [d for d, v in mapper.items() if v == 1]
325325
if level_1:
326326
assert len(level_1) == len(level_0)
327-
assert all(d1.parent is d0 for d0, d1 in zip(level_0, level_1))
327+
assert all(d1.parent is d0 for d0, d1 in zip(level_0, level_1, strict=False))
328328
for bs in list(ret):
329329
handle = []
330330
for v in options['blocksize-l1']:

devito/core/cpu.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,20 @@
1515
)
1616
from devito.tools import timed_pass
1717

18-
__all__ = ['Cpu64NoopCOperator', 'Cpu64NoopOmpOperator', 'Cpu64AdvCOperator',
19-
'Cpu64AdvOmpOperator', 'Cpu64FsgCOperator', 'Cpu64FsgOmpOperator',
20-
'Cpu64CustomOperator', 'Cpu64CustomCXXOperator', 'Cpu64AdvCXXOperator',
21-
'Cpu64AdvCXXOmpOperator', 'Cpu64FsgCXXOperator', 'Cpu64FsgCXXOmpOperator']
18+
__all__ = [
19+
'Cpu64AdvCOperator',
20+
'Cpu64AdvCXXOmpOperator',
21+
'Cpu64AdvCXXOperator',
22+
'Cpu64AdvOmpOperator',
23+
'Cpu64CustomCXXOperator',
24+
'Cpu64CustomOperator',
25+
'Cpu64FsgCOperator',
26+
'Cpu64FsgCXXOmpOperator',
27+
'Cpu64FsgCXXOperator',
28+
'Cpu64FsgOmpOperator',
29+
'Cpu64NoopCOperator',
30+
'Cpu64NoopOmpOperator',
31+
]
2232

2333

2434
class Cpu64OperatorMixin:

0 commit comments

Comments
 (0)