From e00ef8815fdb6707d24a3015fa6324bc83f9b672 Mon Sep 17 00:00:00 2001 From: "Jessica S. Yu" <15913767+jessicasyu@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:22:34 -0400 Subject: [PATCH] Update type hinting and task defaults (#52) * Update default for extract mesh projections task * Remove None type hinting in tests --- src/abm_shape_collection/extract_mesh_projections.py | 5 ++++- .../test_extract_mesh_projections.py | 10 +++++++++- .../test_extract_mesh_wireframe.py | 2 +- .../test_get_shape_coefficients.py | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/abm_shape_collection/extract_mesh_projections.py b/src/abm_shape_collection/extract_mesh_projections.py index 6c9fe3e..34b8e13 100644 --- a/src/abm_shape_collection/extract_mesh_projections.py +++ b/src/abm_shape_collection/extract_mesh_projections.py @@ -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: """ @@ -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) diff --git a/tests/abm_shape_collection/test_extract_mesh_projections.py b/tests/abm_shape_collection/test_extract_mesh_projections.py index df9031b..e6948b3 100644 --- a/tests/abm_shape_collection/test_extract_mesh_projections.py +++ b/tests/abm_shape_collection/test_extract_mesh_projections.py @@ -14,7 +14,7 @@ class TestExtractMeshProjections(unittest.TestCase): - def setUp(self) -> None: + def setUp(self): vertices = [ (-1, -1, 0), (1, -1, 0), @@ -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: diff --git a/tests/abm_shape_collection/test_extract_mesh_wireframe.py b/tests/abm_shape_collection/test_extract_mesh_wireframe.py index 5e6111f..b9e7990 100644 --- a/tests/abm_shape_collection/test_extract_mesh_wireframe.py +++ b/tests/abm_shape_collection/test_extract_mesh_wireframe.py @@ -7,7 +7,7 @@ class TestExtractMeshProjections(unittest.TestCase): - def setUp(self) -> None: + def setUp(self): vertices = [ (-1, -1, 0), (1, -1, 0), diff --git a/tests/abm_shape_collection/test_get_shape_coefficients.py b/tests/abm_shape_collection/test_get_shape_coefficients.py index 3838df3..c0d3bab 100644 --- a/tests/abm_shape_collection/test_get_shape_coefficients.py +++ b/tests/abm_shape_collection/test_get_shape_coefficients.py @@ -6,7 +6,7 @@ class TestGetShapeCoefficients(unittest.TestCase): - def setUp(self) -> None: + def setUp(self): self.order = 2 self.coeff_names = [