Skip to content

Commit 4f50954

Browse files
JDBetteridgeEdCaunt
andcommitted
misc: Apply review suggestions
Co-authored-by: Ed Caunt <ed@devitocodes.com>
1 parent 4b30ce2 commit 4f50954

7 files changed

Lines changed: 12 additions & 13 deletions

File tree

benchmarks/user/benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def run_op(solver, operator, **options):
7171
"""
7272
Initialize any necessary input and run the operator associated with the solver.
7373
"""
74-
# Get the operator if exist
74+
# Get the operator if it exists
7575
try:
7676
op = getattr(solver, operator)
7777
except AttributeError as e:

devito/core/operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def _check_kwargs(cls, **kwargs):
196196
oo = kwargs['options']
197197

198198
if oo['mpi'] and oo['mpi'] not in cls.MPI_MODES:
199-
raise InvalidOperator("Unsupported MPI mode `{}`".format(oo['mpi']))
199+
raise InvalidOperator(f"Unsupported MPI mode `{oo['mpi']}`")
200200

201201
if oo['cse-algo'] not in ('basic', 'smartsort', 'advanced'):
202202
raise InvalidOperator("Illegal `cse-algo` value")

devito/finite_differences/derivative.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ def _eval_at(self, func):
491491
x0 = func.indices_ref.getters
492492
psubs = {}
493493
nx0 = x0.copy()
494-
for d, _ in x0.items():
494+
for d in x0:
495495
if d in self.dims:
496496
# d is a valid Derivative dimension
497497
continue

devito/ir/clusters/visitors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ def __new__(cls, *args, mode='dense'):
141141
elif len(args) == 2:
142142
func, mode = args
143143
else:
144-
raise AssertionError('Too many args')
144+
raise ValueError(
145+
f"Either 1 or 2 arguments permitted, {len(args)} provided"
146+
)
145147
obj = object.__new__(cls)
146148
obj.__init__(func, mode)
147149
return obj

devito/ir/iet/nodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@ def __init__(self, sync_ops, body=None):
15131513
self.sync_ops = sync_ops
15141514

15151515
def __repr__(self):
1516-
return "<SyncSpot ({})>".format(",".join(str(i) for i in self.sync_ops))
1516+
return f"<SyncSpot ({','.join(str(i) for i in self.sync_ops)})>"
15171517

15181518
@property
15191519
def is_async_op(self):
@@ -1590,7 +1590,7 @@ def __init__(self, body, halo_scheme):
15901590
self._halo_scheme = halo_scheme
15911591

15921592
def __repr__(self):
1593-
functions = "({})".format(",".join(i.name for i in self.functions))
1593+
functions = f"({','.join(i.name for i in self.functions)})"
15941594
return f"<{self.__class__.__name__}{functions}>"
15951595

15961596
@property

devito/ir/iet/visitors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def visit_PointerCast(self, o):
479479
elif isinstance(o.obj, IndexedData):
480480
v = f._C_name
481481
else:
482-
raise AssertionError('rvalue is not a recognised type')
482+
raise TypeError('rvalue is not a recognised type')
483483
rvalue = f'({cstr}**) {v}'
484484

485485
else:
@@ -508,7 +508,7 @@ def visit_PointerCast(self, o):
508508
elif isinstance(o.obj, DeviceMap):
509509
v = f._C_field_dmap
510510
else:
511-
raise AssertionError('rvalue is not a recognised type')
511+
raise TypeError('rvalue is not a recognised type')
512512

513513
rvalue = f'({cstr} {rshape}) {f._C_name}->{v}'
514514
else:

devito/ir/stree/algorithms.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,8 @@ def preprocess(clusters, options=None, **kwargs):
228228
processed.append(c)
229229

230230
# Sanity check!
231-
try:
232-
assert not queue
233-
except AssertionError as e:
234-
if options['mpi']:
235-
raise RuntimeError("Unsupported MPI for the given equations") from e
231+
if not queue and options['mpi']:
232+
raise RuntimeError("Unsupported MPI for the given equations")
236233

237234
return processed
238235

0 commit comments

Comments
 (0)