Skip to content

Commit

Permalink
More pylints
Browse files Browse the repository at this point in the history
  • Loading branch information
domfournier committed Jun 17, 2024
1 parent 8ccca8f commit 471426b
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions octree_creation_app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ def densify_curve(curve: Curve, increment: float) -> np.ndarray:
if curve.cells is not None and curve.vertices is not None:
logic = curve.parts == part
cells = curve.cells[np.all(logic[curve.cells], axis=1)]

if len(cells) == 0:
continue

Check warning on line 145 in octree_creation_app/utils.py

View check run for this annotation

Codecov / codecov/patch

octree_creation_app/utils.py#L145

Added line #L145 was not covered by tests

vert_ind = np.r_[cells[:, 0], cells[-1, 1]]
locs = curve.vertices[vert_ind, :]
locations.append(resample_locations(locs, increment))
Expand Down Expand Up @@ -232,12 +236,26 @@ def octree_2_treemesh( # pylint: disable=too-many-locals
:return: Resulting TreeMesh.
"""
if mesh.octree_cells is None:
if (
mesh.octree_cells is None
or mesh.u_count is None
or mesh.v_count is None
or mesh.w_count is None
):
return None

small_cell = [mesh.u_cell_size, mesh.v_cell_size, mesh.w_cell_size]
n_cell_dim = [mesh.u_count, mesh.v_count, mesh.w_count]
cell_sizes = [np.ones(nr) * sz for nr, sz in zip(n_cell_dim, small_cell)]
n_cell_dim, cell_sizes = [], []
for ax in "uvw":
if (
getattr(mesh, f"{ax}_cell_size") is None
or getattr(mesh, f"{ax}_count") is None
):
raise ValueError(f"Cell size in {ax} direction is not defined.")

Check warning on line 253 in octree_creation_app/utils.py

View check run for this annotation

Codecov / codecov/patch

octree_creation_app/utils.py#L253

Added line #L253 was not covered by tests

n_cell_dim.append(getattr(mesh, f"{ax}_count"))
cell_sizes.append(
np.ones(getattr(mesh, f"{ax}_count")) * getattr(mesh, f"{ax}_cell_size")
)

if any(np.any(cell_size < 0) for cell_size in cell_sizes):
raise NotImplementedError("Negative cell sizes not supported.")
Expand Down

0 comments on commit 471426b

Please sign in to comment.