Skip to content

Commit 2ccf2ab

Browse files
committed
lint: First pass with ruff --fix
1 parent 7fef2f5 commit 2ccf2ab

File tree

130 files changed

+1215
-895
lines changed

Some content is hidden

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

130 files changed

+1215
-895
lines changed

benchmarks/user/advisor/roofline.py

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

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

devito/arch/archinfo.py

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

5353
# Obtain textual cpu info
5454
try:
55-
with open('/proc/cpuinfo', 'r') as f:
55+
with open('/proc/cpuinfo') as f:
5656
lines = f.readlines()
5757
except FileNotFoundError:
5858
lines = []
@@ -731,9 +731,7 @@ def get_platform():
731731
elif 'intel' in brand:
732732
# Most likely a desktop i3/i5/i7
733733
return platform_registry['intel64']
734-
elif 'power8' in brand:
735-
return platform_registry['power8']
736-
elif 'power9' in brand:
734+
elif 'power8' in brand or 'power9' in brand:
737735
return platform_registry['power8']
738736
elif 'arm' in brand:
739737
return platform_registry['arm']

devito/arch/compiler.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from devito.tools import (as_list, change_directory, filter_ordered,
2626
memoized_func, make_tempdir)
2727

28-
__all__ = ['sniff_mpi_distro', 'compiler_registry']
28+
__all__ = ['compiler_registry', 'sniff_mpi_distro']
2929

3030

3131
@memoized_func
@@ -53,11 +53,7 @@ def sniff_compiler_version(cc, allow_fail=False):
5353
ver = ver.strip()
5454
if ver.startswith("gcc"):
5555
compiler = "gcc"
56-
elif ver.startswith("clang"):
57-
compiler = "clang"
58-
elif ver.startswith("Apple LLVM"):
59-
compiler = "clang"
60-
elif ver.startswith("Homebrew clang"):
56+
elif ver.startswith("clang") or ver.startswith("Apple LLVM") or ver.startswith("Homebrew clang"):
6157
compiler = "clang"
6258
elif ver.startswith("Intel"):
6359
compiler = "icx"
@@ -340,22 +336,21 @@ def make(self, loc, args):
340336
logfile = path.join(self.get_jit_dir(), f"{hash_key}.log")
341337
errfile = path.join(self.get_jit_dir(), f"{hash_key}.err")
342338

343-
with change_directory(loc):
344-
with open(logfile, "w") as lf:
345-
with open(errfile, "w") as ef:
346-
347-
command = ['make'] + args
348-
lf.write("Compilation command:\n")
349-
lf.write(" ".join(command))
350-
lf.write("\n\n")
351-
try:
352-
check_call(command, stderr=ef, stdout=lf)
353-
except CalledProcessError as e:
354-
raise CompilationError(f'Command "{e.cmd}" return error status'
355-
f'{e.returncode}. '
356-
f'Unable to compile code.\n'
357-
f'Compile log in {logfile}\n'
358-
f'Compile errors in {errfile}\n')
339+
with change_directory(loc), open(logfile, "w") as lf:
340+
with open(errfile, "w") as ef:
341+
342+
command = ['make'] + args
343+
lf.write("Compilation command:\n")
344+
lf.write(" ".join(command))
345+
lf.write("\n\n")
346+
try:
347+
check_call(command, stderr=ef, stdout=lf)
348+
except CalledProcessError as e:
349+
raise CompilationError(f'Command "{e.cmd}" return error status'
350+
f'{e.returncode}. '
351+
f'Unable to compile code.\n'
352+
f'Compile log in {logfile}\n'
353+
f'Compile errors in {errfile}\n')
359354
debug(f"Make <{' '.join(args)}>")
360355

361356
def _cmdline(self, files, object=False):
@@ -393,7 +388,7 @@ def jit_compile(self, soname, code):
393388
# Warning: dropping `code` on the floor in favor to whatever is written
394389
# within `src_file`
395390
try:
396-
with open(src_file, 'r') as f:
391+
with open(src_file) as f:
397392
code = f.read()
398393
code = f'{code}/* Backdoor edit at {time.ctime()}*/ \n'
399394
# 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 make_retval, check_builtins_args
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from devito.tools import as_tuple, as_list
55
from devito.builtins.utils import check_builtins_args, nbl_to_padsize, pad_outhalo
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')

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
@@ -2,8 +2,12 @@
22
Cpu64AdvCOperator)
33
from devito.passes.iet import OmpTarget, CXXOmpTarget
44

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

812

913
ArmAdvOperator = Cpu64AdvOperator

devito/core/cpu.py

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

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

2232

2333
class Cpu64OperatorMixin:

devito/core/gpu.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,23 @@
1515
relax_incr_dimensions, check_stability)
1616
from devito.tools import as_tuple, timed_pass
1717

18-
__all__ = ['DeviceNoopOperator', 'DeviceAdvOperator', 'DeviceCustomOperator',
19-
'DeviceNoopOmpOperator', 'DeviceAdvOmpOperator', 'DeviceFsgOmpOperator',
20-
'DeviceCustomOmpOperator', 'DeviceNoopAccOperator', 'DeviceAdvAccOperator',
21-
'DeviceFsgAccOperator', 'DeviceCustomAccOperator', 'DeviceNoopCXXOmpOperator',
22-
'DeviceAdvCXXOmpOperator', 'DeviceFsgCXXOmpOperator',
23-
'DeviceCustomCXXOmpOperator']
18+
__all__ = [
19+
'DeviceAdvAccOperator',
20+
'DeviceAdvCXXOmpOperator',
21+
'DeviceAdvOmpOperator',
22+
'DeviceAdvOperator',
23+
'DeviceCustomAccOperator',
24+
'DeviceCustomCXXOmpOperator',
25+
'DeviceCustomOmpOperator',
26+
'DeviceCustomOperator',
27+
'DeviceFsgAccOperator',
28+
'DeviceFsgCXXOmpOperator',
29+
'DeviceFsgOmpOperator',
30+
'DeviceNoopAccOperator',
31+
'DeviceNoopCXXOmpOperator',
32+
'DeviceNoopOmpOperator',
33+
'DeviceNoopOperator',
34+
]
2435

2536

2637
class DeviceOperatorMixin:

devito/core/intel.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
Cpu64AdvCXXOperator, Cpu64AdvCXXOmpOperator,
44
Cpu64FsgCXXOperator, Cpu64FsgCXXOmpOperator)
55

6-
__all__ = ['Intel64AdvCOperator', 'Intel64AdvOmpOperator', 'Intel64FsgCOperator',
7-
'Intel64FsgOmpOperator', 'Intel64CXXAdvCOperator', 'Intel64AdvCXXOmpOperator',
8-
'Intel64FsgCXXOperator', 'Intel64FsgCXXOmpOperator']
6+
__all__ = [
7+
'Intel64AdvCOperator',
8+
'Intel64AdvCXXOmpOperator',
9+
'Intel64AdvOmpOperator',
10+
'Intel64CXXAdvCOperator',
11+
'Intel64FsgCOperator',
12+
'Intel64FsgCXXOmpOperator',
13+
'Intel64FsgCXXOperator',
14+
'Intel64FsgOmpOperator',
15+
]
916

1017

1118
Intel64AdvCOperator = Cpu64AdvCOperator

0 commit comments

Comments
 (0)