Skip to content

Commit

Permalink
misc: Convert into f-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioLuporini committed Dec 20, 2024
1 parent 1424bf4 commit f39a347
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions devito/operator/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def _sanitize_exprs(cls, expressions, **kwargs):

for i in expressions:
if not isinstance(i, Evaluable):
raise CompilationError("`%s` is not an Evaluable object, "
"check again your Equation" % str(i))
raise CompilationError(f"`{i!s}` is not an Evaluable object; "
"check your equation again")

return expressions

Expand Down Expand Up @@ -554,7 +554,7 @@ def _prepare_arguments(self, autotune=None, **kwargs):
if not configuration['ignore-unknowns']:
for k, v in kwargs.items():
if k not in self._known_arguments:
raise InvalidArgument("Unrecognized argument %s=%s" % (k, v))
raise InvalidArgument(f"Unrecognized argument `{k}={v}`")

# Pre-process Dimension overrides. This may help ruling out ambiguities
# when processing the `defaults` arguments. A topological sorting is used
Expand Down Expand Up @@ -584,9 +584,9 @@ def _prepare_arguments(self, autotune=None, **kwargs):
try:
args.reduce_inplace()
except ValueError:
v = [i for i in overrides if i.name in args]
raise InvalidArgument(
"Override `%s` is incompatible with overrides `%s`" %
(p, [i for i in overrides if i.name in args])
f"Override `{p}` is incompatible with overrides `{v}`"
)

# Process data-carrier defaults
Expand All @@ -608,9 +608,9 @@ def _prepare_arguments(self, autotune=None, **kwargs):
pass
elif is_integer(args[k]) and not contains_val(args[k], v):
raise InvalidArgument(
"Default `%s` is incompatible with other args as `%s=%s`, "
"while `%s=%s` is expected. Perhaps you forgot to override "
"`%s`?" % (p, k, v, k, args[k], p)
f"Default `{p}` is incompatible with other args as "
f"`{k}={v}`, while `{k}={args[k]}` is expected. Perhaps "
f"you forgot to override `{p}`?"
)

args = kwargs['args'] = args.reduce_all()
Expand Down Expand Up @@ -742,7 +742,7 @@ def arguments(self, **kwargs):
# Check all arguments are present
for p in self.parameters:
if args.get(p.name) is None:
raise InvalidArgument("No value found for parameter %s" % p.name)
raise InvalidArgument(f"No value found for parameter `{p.name}`")
return args

# Code generation and JIT compilation
Expand Down
4 changes: 2 additions & 2 deletions devito/passes/clusters/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ def _select(self, variants):
return variants[self.opt_schedule_strategy]
except IndexError:
raise CompilationError(
"Illegal schedule %d; generated %d schedules in total"
% (self.opt_schedule_strategy, len(variants))
f"Illegal schedule {self.opt_schedule_strategy}; "
f"generated {len(variants)} schedules in total"
)

return pick_best(variants)
Expand Down
4 changes: 2 additions & 2 deletions devito/passes/clusters/buffering.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ def generate_buffers(clusters, key, sregistry, options, **kwargs):

dims = [d for d in f.dimensions if d not in bdims]
if len(dims) != 1:
raise CompilationError("Unsupported multi-dimensional `buffering` "
"required by `%s`" % f)
raise CompilationError(f"Unsupported multi-dimensional `buffering` "
f"required by `{f}`")
dim = dims.pop()

if is_buffering(exprs):
Expand Down
4 changes: 2 additions & 2 deletions devito/types/dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -1375,8 +1375,8 @@ def __init_finalize__(self, *args, **kwargs):
required_mem = np.dtype(self.dtype).itemsize * self.size
if required_mem > available_mem:
raise MemoryError(
"Trying to allocate more memory (%s) for `%s` than available (%s)"
% (humanbytes(required_mem), self.name, humanbytes(available_mem))
f"Trying to allocate more memory ({humanbytes(required_mem)}) "
f"for `{self.name}` than available ({humanbytes(available_mem)})"
)
if not isinstance(self.time_order, int):
raise TypeError("`time_order` must be int")
Expand Down

0 comments on commit f39a347

Please sign in to comment.