From 40003c560722944b2f307ec65a9cbf7fa135d88e Mon Sep 17 00:00:00 2001 From: Niklas Melton Date: Wed, 23 Jul 2025 19:56:40 -0500 Subject: [PATCH 1/2] perimiter only logic was swapped --- pyalphashape/AlphaShape.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyalphashape/AlphaShape.py b/pyalphashape/AlphaShape.py index 6d88c89..b673485 100644 --- a/pyalphashape/AlphaShape.py +++ b/pyalphashape/AlphaShape.py @@ -266,9 +266,9 @@ def add_points(self, new_pts: np.ndarray, perimeter_only: bool = False) -> None: """ if perimeter_only: - pts = np.vstack([self.points, new_pts]) - else: pts = np.vstack([self.perimeter_points, new_pts]) + else: + pts = np.vstack([self.points, new_pts]) self.__init__( # type: ignore[misc] pts, alpha=self.alpha, From d50e1afc26ede55a60db3020a2acb0e312646c60 Mon Sep 17 00:00:00 2001 From: Niklas Melton Date: Wed, 23 Jul 2025 20:02:53 -0500 Subject: [PATCH 2/2] update tests --- unit_tests/test_AlphaShape.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/unit_tests/test_AlphaShape.py b/unit_tests/test_AlphaShape.py index de76d5d..82ac2f6 100644 --- a/unit_tests/test_AlphaShape.py +++ b/unit_tests/test_AlphaShape.py @@ -90,14 +90,29 @@ def test_distance_to_surface_various_cases(): def test_add_points_grows_shape(): - points = np.array([[0, 0], [1, 0], [0.5, 1]]) - shape = AlphaShape(points, alpha=3.0) + points = np.array([[0, 0], [1, 0], [0, 1]]) + shape = AlphaShape(points, alpha=0.0) n_perim_before = len(shape.perimeter_points) - shape.add_points(np.array([[0.5, 1.5]]), perimeter_only=False) + shape.add_points(np.array([[1, 1]]), perimeter_only=False) n_perim_after = len(shape.perimeter_points) assert n_perim_after > n_perim_before +def test_add_points_perimeter_only(): + points = np.array([[0, 0], [1, 0], [0.1, 1]]) + shape = AlphaShape(points, alpha=0.0) + shape.add_points(np.array([[0, 2]]), perimeter_only=True) + n_perim_after = len(shape.perimeter_points) + assert n_perim_after == 3 + +def test_add_points_all_points(): + points = np.array([[0, 0], [1, 0], [0.1, 1]]) + shape = AlphaShape(points, alpha=10.0, connectivity="relaxed") + shape.add_points(np.array([[0, 2]]), perimeter_only=False) + n_perim_after = len(shape.perimeter_points) + assert n_perim_after == 4 + + def test_get_boundary_facets_returns_facets(): points = np.random.rand(10, 3) shape = AlphaShape(points, alpha=1.0)