Skip to content

Commit

Permalink
Update type hinting and task defaults (#52)
Browse files Browse the repository at this point in the history
* Update default for extract mesh projections task

* Remove None type hinting in tests
  • Loading branch information
jessicasyu authored Sep 25, 2024
1 parent 78e793e commit e00ef88
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/abm_shape_collection/extract_mesh_projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ProjectionType(Enum):

def extract_mesh_projections(
mesh: vtkPolyData | trimesh.Trimesh,
projection_types: list[ProjectionType],
projection_types: list[ProjectionType] | None = None,
offset: tuple[float, float, float] | None = None,
) -> dict:
"""
Expand Down Expand Up @@ -56,6 +56,9 @@ def extract_mesh_projections(
if isinstance(mesh, vtkPolyData):
mesh = convert_vtk_to_trimesh(mesh)

if projection_types is None:
projection_types = [ProjectionType.SLICE, ProjectionType.EXTENT]

if offset is not None:
mesh.apply_translation(offset)

Expand Down
10 changes: 9 additions & 1 deletion tests/abm_shape_collection/test_extract_mesh_projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class TestExtractMeshProjections(unittest.TestCase):
def setUp(self) -> None:
def setUp(self):
vertices = [
(-1, -1, 0),
(1, -1, 0),
Expand Down Expand Up @@ -116,6 +116,14 @@ def setUp(self) -> None:
},
}

def test_extract_mesh_projections_all_types_no_translation(self):
projections = extract_mesh_projections(self.vtk_mesh)
for proj, _, _ in PROJECTIONS:
self.assertCountEqual(self.slices[proj], projections[f"{proj}_slice"])
self.assertDictEqual(self.extents[proj], projections[f"{proj}_extent"])
self.assertFalse(f"{proj}_extent" in proj)
self.assertFalse(f"{proj}_slice" in proj)

def test_extract_mesh_projections_slices_no_translation(self):
projections = extract_mesh_projections(self.vtk_mesh, [ProjectionType.SLICE], offset=None)
for proj, _, _ in PROJECTIONS:
Expand Down
2 changes: 1 addition & 1 deletion tests/abm_shape_collection/test_extract_mesh_wireframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class TestExtractMeshProjections(unittest.TestCase):
def setUp(self) -> None:
def setUp(self):
vertices = [
(-1, -1, 0),
(1, -1, 0),
Expand Down
2 changes: 1 addition & 1 deletion tests/abm_shape_collection/test_get_shape_coefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class TestGetShapeCoefficients(unittest.TestCase):
def setUp(self) -> None:
def setUp(self):
self.order = 2

self.coeff_names = [
Expand Down

0 comments on commit e00ef88

Please sign in to comment.