Skip to content

Commit

Permalink
Handle use-before-assign warnings from pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed May 20, 2024
1 parent c2be523 commit b5f253e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
9 changes: 5 additions & 4 deletions examples/advection/var-velocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,13 @@ def rhs(t, u):
norm_u = actx.to_numpy(op.norm(dcoll, event.state_component, 2))
plot(event, "fld-var-velocity-%04d" % step)

logger.info("[%04d] t = %.5f |u| = %.5e", step, event.t, norm_u)
# NOTE: These are here to ensure the solution is bounded for the
# time interval specified
assert norm_u < 1

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

# NOTE: These are here to ensure the solution is bounded for the
# time interval specified
assert norm_u < 1

# }}}

Expand Down
16 changes: 12 additions & 4 deletions grudge/models/em.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ def flux(self, wtpair):
e, h = self.split_eh(wtpair)
epsilon = self.epsilon
mu = self.mu
else:
raise NotImplementedError("only fixed material spported for now")

Z_int = (mu/epsilon)**0.5 # noqa: N806
Y_int = 1/Z_int # noqa: N806
Expand Down Expand Up @@ -348,6 +350,8 @@ def absorbing_bc(self, w):
if self.fixed_material:
epsilon = self.epsilon
mu = self.mu
else:
raise NotImplementedError("only fixed material supported for now")

absorb_Z = (mu/epsilon)**0.5 # noqa: N806
absorb_Y = 1/absorb_Z # noqa: N806
Expand Down Expand Up @@ -394,6 +398,8 @@ def operator(self, t, w):
# need to check this
material_divisor = (
[self.epsilon]*elec_components+[self.mu]*mag_components)
else:
raise NotImplementedError("only fixed material supported for now")

tags_and_bcs = [
(self.pec_tag, self.pec_bc(w)),
Expand Down Expand Up @@ -567,9 +573,6 @@ def get_rectangular_cavity_mode(actx, nodes, t, E_0, mode_indices): # noqa: N80
cx = actx.np.cos(kx*x)
sy = actx.np.sin(ky*y)
cy = actx.np.cos(ky*y)
if dims == 3:
sz = actx.np.sin(kz*z)
cz = actx.np.cos(kz*z)

if dims == 2:
tfac = t * omega
Expand All @@ -584,7 +587,10 @@ def get_rectangular_cavity_mode(actx, nodes, t, E_0, mode_indices): # noqa: N80
* np.sin(tfac) / omega), # hy
zeros,
)
else:
elif dims == 3:
sz = actx.np.sin(kz*z)
cz = actx.np.cos(kz*z)

tdep = np.exp(-1j * omega * t)

gamma_squared = ky**2 + kx**2
Expand All @@ -596,6 +602,8 @@ def get_rectangular_cavity_mode(actx, nodes, t, E_0, mode_indices): # noqa: N80
1j * omega * kx*E_0*cx*sy*cz*tdep / gamma_squared,
zeros,
)
else:
raise NotImplementedError("only 2D and 3D supported")

return result

Expand Down
2 changes: 1 addition & 1 deletion test/test_grudge.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def test_face_normal_surface(actx_factory, mesh_name):
dof_desc.FACE_RESTR_INTERIOR, dof_desc.VTAG_ALL)
)(face_normal_i)

if mesh.ambient_dim == 3:
if ambient_dim == 3:
from grudge.geometry import pseudoscalar, area_element
# NOTE: there's only one face tangent in 3d
face_tangent = (
Expand Down

0 comments on commit b5f253e

Please sign in to comment.