From 05098c0c13bc2622f48b4b0f1b01d53d0cc11949 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sat, 14 Feb 2026 19:15:54 -0800 Subject: [PATCH] [remove_colinear_vertices] keep two vertices if all were colinear --- masque/utils/vertices.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/masque/utils/vertices.py b/masque/utils/vertices.py index 5fddd52..36d2e59 100644 --- a/masque/utils/vertices.py +++ b/masque/utils/vertices.py @@ -51,6 +51,10 @@ def remove_colinear_vertices(vertices: ArrayLike, closed_path: bool = True) -> N if not closed_path: slopes_equal[[0, -1]] = False + if slopes_equal.all() and vertices.shape[0] > 0: + # All colinear, keep the first and last + return vertices[[0, vertices.shape[0] - 1]] + return vertices[~slopes_equal]