diff --git a/masque/shapes/arc.py b/masque/shapes/arc.py index f95c4f6..6f948cb 100644 --- a/masque/shapes/arc.py +++ b/masque/shapes/arc.py @@ -272,13 +272,16 @@ class Arc(PositionableImpl, Shape): arc_lengths, thetas = get_arclens(n_pts, *a_ranges[0 if inner else 1], dr=dr) keep = [0] - removable = (numpy.cumsum(arc_lengths) <= max_arclen) - start = 1 + start = 0 while start < arc_lengths.size: - next_to_keep = start + numpy.where(removable)[0][-1] # TODO: any chance we haven't sampled finely enough? + removable = (numpy.cumsum(arc_lengths[start:]) <= max_arclen) + if not removable.any(): + next_to_keep = start + 1 + else: + next_to_keep = start + numpy.where(removable)[0][-1] + 1 keep.append(next_to_keep) - removable = (numpy.cumsum(arc_lengths[next_to_keep + 1:]) <= max_arclen) - start = next_to_keep + 1 + start = next_to_keep + if keep[-1] != thetas.size - 1: keep.append(thetas.size - 1)