Skip to content

Commit 4e3cfd2

Browse files
exception add if new_rings is none (#3574)
* exception add if new_rings is none * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 3b496ea commit 4e3cfd2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

manim/utils/space_ops.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,9 +755,14 @@ def earclip_triangulation(verts: np.ndarray, ring_ends: list) -> list:
755755

756756
# Move the ring which j belongs to from the
757757
# attached list to the detached list
758-
new_ring = next(filter(lambda ring: ring[0] <= j < ring[-1], detached_rings))
759-
detached_rings.remove(new_ring)
760-
attached_rings.append(new_ring)
758+
new_ring = next(
759+
(ring for ring in detached_rings if ring[0] <= j < ring[-1]), None
760+
)
761+
if new_ring is not None:
762+
detached_rings.remove(new_ring)
763+
attached_rings.append(new_ring)
764+
else:
765+
raise Exception("Could not find a ring to attach")
761766

762767
# Setup linked list
763768
after = []

0 commit comments

Comments
 (0)