Skip to content

Commit

Permalink
Reenable ruff C409, fix/ignore issues
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Aug 11, 2024
1 parent ffa34b8 commit 1028fc2
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 30 deletions.
5 changes: 2 additions & 3 deletions meshmode/discretization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,8 @@ def resample_mesh_nodes(grp, iaxis):
NameHint(name_hint)))

result = make_obj_array([
_DOFArray(None, tuple([
actx.freeze(resample_mesh_nodes(grp, iaxis)) for grp in self.groups
]))
_DOFArray(None, tuple(actx.freeze(resample_mesh_nodes(grp, iaxis))
for grp in self.groups))
for iaxis in range(self.ambient_dim)])
if cached:
self._cached_nodes = result
Expand Down
3 changes: 2 additions & 1 deletion meshmode/dof_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ def _raise_index_inconsistency(i, stream_i):
else:
return type(template)(
template.array_context,
data=tuple([v for _i, v in iterable]))
# NOTE: tuple([]) is faster, and this is a cost-sensitive code path.
data=tuple([v for _i, v in iterable])) # noqa: C409


@with_array_context.register(DOFArray)
Expand Down
6 changes: 2 additions & 4 deletions meshmode/interop/firedrake/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,8 @@ def _get_firedrake_facial_adjacency_groups(fdrake_mesh_topology,
# )
# and meshmode's facet ordering: obtained from a simplex element group
import modepy as mp
mm_face_vertex_indices = tuple([
face.volume_vertex_indices
for face in mp.faces_for_shape(mp.Simplex(top.cell_dimension()))
])
mm_face_vertex_indices = tuple(face.volume_vertex_indices
for face in mp.faces_for_shape(mp.Simplex(top.cell_dimension())))

# map firedrake local face number to meshmode local face number
fd_loc_fac_nr_to_mm = {}
Expand Down
6 changes: 2 additions & 4 deletions meshmode/mesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def _modepy_faces(self) -> Sequence[mp.Face]:

@memoize_method
def face_vertex_indices(self) -> tuple[tuple[int, ...], ...]:
return tuple([face.volume_vertex_indices for face in self._modepy_faces])
return tuple(face.volume_vertex_indices for face in self._modepy_faces)

@memoize_method
def vertex_unit_coordinates(self) -> np.ndarray:
Expand Down Expand Up @@ -1052,9 +1052,7 @@ def make_mesh(
facial_adjacency_groups,
element_id_dtype,
face_id_dtype)
facial_adjacency_groups = tuple([
tuple(grps) for grps in facial_adjacency_groups
])
facial_adjacency_groups = tuple(tuple(grps) for grps in facial_adjacency_groups)

mesh = Mesh(
groups=tuple(groups),
Expand Down
18 changes: 8 additions & 10 deletions meshmode/mesh/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1380,9 +1380,8 @@ def glue_mesh_boundaries(

return mesh.copy(
nodal_adjacency=False,
_facial_adjacency_groups=tuple([
tuple(fagrps) for fagrps in facial_adjacency_groups
]),
_facial_adjacency_groups=tuple(
tuple(fagrps) for fagrps in facial_adjacency_groups),
)

# }}}
Expand Down Expand Up @@ -1526,9 +1525,10 @@ def compute_new_map(old_map: AffineMap) -> AffineMap:
return mesh.copy(
vertices=vertices,
groups=tuple(new_groups),
_facial_adjacency_groups=tuple([
tuple(fagrps) for fagrps in facial_adjacency_groups
]) if facial_adjacency_groups is not None else None,
_facial_adjacency_groups=tuple(
tuple(fagrps)
for fagrps in facial_adjacency_groups)
if facial_adjacency_groups is not None else None,
is_conforming=mesh.is_conforming)


Expand Down Expand Up @@ -1602,10 +1602,8 @@ def make_mesh_grid(

from pytools import wandering_element
size = bmax - bmin
offset = tuple([
np.array(e_i) * (size[i] + 0.25 * size[i])
for i, e_i in enumerate(wandering_element(mesh.ambient_dim))
])
offset = tuple(np.array(e_i) * (size[i] + 0.25 * size[i])
for i, e_i in enumerate(wandering_element(mesh.ambient_dim)))

if len(offset) != mesh.ambient_dim:
raise ValueError("must provide an offset per dimension")
Expand Down
4 changes: 1 addition & 3 deletions meshmode/mesh/refinement/tessellate.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ def _get_group_tessellation_info_modepy(meg: _ModepyElementGroup):
from pytools import add_tuples
space = mp.space_for_shape(shape, 1)
assert type(space) == type(meg._modepy_space) # noqa: E721
orig_vertices = tuple([
add_tuples(vt, vt) for vt in mp.node_tuples_for_space(space)
])
orig_vertices = tuple(add_tuples(vt, vt) for vt in mp.node_tuples_for_space(space))
orig_vertex_indices = [ref_vertices_to_index[vt] for vt in orig_vertices]

midpoints = _get_ref_midpoints(shape, ref_vertices)
Expand Down
6 changes: 2 additions & 4 deletions meshmode/mesh/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,10 @@ def visualize_mesh_vertex_resampling_error(

from meshmode.dof_array import DOFArray
from meshmode.mesh import _mesh_group_node_vertex_error
error = DOFArray(actx, tuple([
actx.from_numpy(
error = DOFArray(actx, tuple(actx.from_numpy(
np.sqrt(np.sum(_mesh_group_node_vertex_error(mesh, mgrp)**2, axis=0))
)
for mgrp in mesh.groups
]))
for mgrp in mesh.groups))

# }}}

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ extend-select = [
"W", # pycodestyle
]
extend-ignore = [
"C409", # remove comprehension within tuple call
"C90", # McCabe complexity
"E226", # missing whitespace around arithmetic operator
"E241", # multiple spaces after comma
Expand Down

0 comments on commit 1028fc2

Please sign in to comment.