From 4e3cfd207a16458b8781c10b88405657f44913ac Mon Sep 17 00:00:00 2001 From: Hydromel Victor Doledji Date: Thu, 11 Jan 2024 13:23:49 +0000 Subject: [PATCH] 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> --- manim/utils/space_ops.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/manim/utils/space_ops.py b/manim/utils/space_ops.py index 973502aafc..3e90deef21 100644 --- a/manim/utils/space_ops.py +++ b/manim/utils/space_ops.py @@ -755,9 +755,14 @@ def earclip_triangulation(verts: np.ndarray, ring_ends: list) -> list: # Move the ring which j belongs to from the # attached list to the detached list - new_ring = next(filter(lambda ring: ring[0] <= j < ring[-1], detached_rings)) - detached_rings.remove(new_ring) - attached_rings.append(new_ring) + new_ring = next( + (ring for ring in detached_rings if ring[0] <= j < ring[-1]), None + ) + if new_ring is not None: + detached_rings.remove(new_ring) + attached_rings.append(new_ring) + else: + raise Exception("Could not find a ring to attach") # Setup linked list after = []