From 47636686cb0dd2a1d7addbf94e560c2525e972e2 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 20 Apr 2022 21:51:56 -0700 Subject: [PATCH] Cleanup extract_mobject_family_members --- manimlib/utils/family_ops.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/manimlib/utils/family_ops.py b/manimlib/utils/family_ops.py index fc1a8b93..8468e74a 100644 --- a/manimlib/utils/family_ops.py +++ b/manimlib/utils/family_ops.py @@ -1,6 +1,5 @@ from __future__ import annotations -import itertools as it from typing import Iterable from typing import TYPE_CHECKING @@ -11,15 +10,14 @@ if TYPE_CHECKING: def extract_mobject_family_members( mobject_list: Iterable[Mobject], - only_those_with_points: bool = False + exclude_pointless: bool = False ) -> list[Mobject]: - result = list(it.chain(*[ - mob.get_family() + return [ + sm for mob in mobject_list - ])) - if only_those_with_points: - result = [mob for mob in result if mob.has_points()] - return result + for sm in mob.get_family() + if (not exclude_pointless) or sm.has_points() + ] def restructure_list_to_exclude_certain_family_members(