From b6231309bfd1675c2b1cc20df57b17dffc880479 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Mon, 8 Jul 2024 17:00:34 -0400 Subject: [PATCH] restrict length --- src/useq/_point_visiting.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/useq/_point_visiting.py b/src/useq/_point_visiting.py index 6ae2b864..b656b170 100644 --- a/src/useq/_point_visiting.py +++ b/src/useq/_point_visiting.py @@ -108,6 +108,8 @@ class TraversalOrder(Enum): def order_points(self, points: np.ndarray, start_at: int = 0) -> np.ndarray: """Return the order of points based on the traversal order.""" + if len(points) <= 2: # no sense in optimizing + return np.arange(len(points)) start_at = min(start_at, len(points) - 1) if self == TraversalOrder.NEAREST_NEIGHBOR: return _nearest_neighbor_order(points, start_at)