Skip to content

Commit

Permalink
fix new ruff UP031 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl authored and inducer committed Aug 19, 2024
1 parent ca4270b commit cdd16aa
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/advection/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def rhs(t, u):
step = 0

event = dt_stepper.StateComputed(0.0, 0, 0, u0)
plot(event, "fld-surface-%04d" % 0)
plot(event, f"fld-surface-{0:04d}")

if visualize and dim == 3:
from grudge.shortcuts import make_visualizer
Expand Down Expand Up @@ -253,7 +253,7 @@ def rhs(t, u):
step += 1
if step % 10 == 0:
norm_u = actx.to_numpy(op.norm(dcoll, event.state_component, 2))
plot(event, "fld-surface-%04d" % step)
plot(event, f"fld-surface-{step:04d}")

logger.info("[%04d] t = %.5f |u| = %.5e", step, event.t, norm_u)

Expand Down
2 changes: 1 addition & 1 deletion examples/advection/var-velocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def rhs(t, u):

if step % 10 == 0:
norm_u = actx.to_numpy(op.norm(dcoll, event.state_component, 2))
plot(event, "fld-var-velocity-%04d" % step)
plot(event, f"fld-var-velocity-{step:04d}")

logger.info("[%04d] t = %.5f |u| = %.5e", step, event.t, norm_u)
# NOTE: These are here to ensure the solution is bounded for the
Expand Down
2 changes: 1 addition & 1 deletion examples/advection/weak.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def rhs(t, u):

if step % 10 == 0:
norm_u = actx.to_numpy(op.norm(dcoll, event.state_component, 2))
plot(event, "fld-weak-%04d" % step)
plot(event, f"fld-weak-{step:04d}")

step += 1
logger.info("[%04d] t = %.5f |u| = %.5e", step, event.t, norm_u)
Expand Down
2 changes: 1 addition & 1 deletion grudge/geometry/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ def second_fundamental_form(
elif dim == 2:
second_ref_axes = [((0, 2),), ((0, 1), (1, 1)), ((1, 2),)]
else:
raise ValueError("%dD surfaces not supported" % dim)
raise ValueError(f"{dim}D surfaces not supported")

from pytools import flatten

Expand Down
5 changes: 3 additions & 2 deletions grudge/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ def _gradient_kernel(actx, out_discr, in_discr, get_diff_mat, inv_jac_mat, vec,
inv_jac_mat)]

return make_obj_array([
DOFArray(
actx, data=tuple([pgg_i[xyz_axis] for pgg_i in per_group_grads]))
DOFArray(actx, data=tuple([ # noqa: C409
pgg_i[xyz_axis] for pgg_i in per_group_grads
]))
for xyz_axis in range(out_discr.ambient_dim)])


Expand Down
6 changes: 3 additions & 3 deletions test/test_grudge.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ def test_convergence_advec(actx_factory, mesh_name, mesh_pars, op_type, flux_typ
elif dim == 3:
dt_factor = 2
else:
raise ValueError("dt_factor not known for %dd" % dim)
raise ValueError(f"dt_factor not known for {dim}d")
elif mesh_name.startswith("warped"):
dim = int(mesh_name[-1:])
mesh = mgen.generate_warped_rect_mesh(dim, order=order,
Expand All @@ -795,7 +795,7 @@ def test_convergence_advec(actx_factory, mesh_name, mesh_pars, op_type, flux_typ
elif dim == 3:
dt_factor = 2
else:
raise ValueError("dt_factor not known for %dd" % dim)
raise ValueError(f"dt_factor not known for {dim}d")
else:
raise ValueError("invalid mesh name: " + mesh_name)

Expand Down Expand Up @@ -861,7 +861,7 @@ def rhs(t, u, adv_operator=adv_operator):

if visualize:
vis.write_vtk_file(
"fld-%s-%04d.vtu" % (mesh_par, step),
f"fld-{mesh_par}-{step:04d}vtu" % (mesh_par, step),
[("u", u)]
)

Expand Down

0 comments on commit cdd16aa

Please sign in to comment.