Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Add docstring to :meth:`Mobject.family_members_with_points` (#4128)

Irvanal Haqc53ac5544aea
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py
index 518dd43b5..f46679e75 100644
--- a/manim/mobject/mobject.py
+++ b/manim/mobject/mobject.py
@@ -2319,7 +2319,7 @@ class Mobject:
Returns
-------
- list
+ list[Mobject]
A list of mobjects in the family of the given mobject.
Examples
@@ -2333,12 +2333,39 @@ class Mobject:
>>> gr.get_family()
[Group, VGroup(Square, Rectangle), Square, Rectangle, Mobject, VMobject]
+ See also
+ --------
+ :meth:`~.Mobject.family_members_with_points`, :meth:`~.Mobject.align_data`
+
"""
sub_families = [x.get_family() for x in self.submobjects]
all_mobjects = [self] + list(it.chain(*sub_families))
return remove_list_redundancies(all_mobjects)
def family_members_with_points(self) -> list[Self]:
+ """Filters the list of family members (generated by :meth:`.get_family`) to include only mobjects with points.
+
+ Returns
+ -------
+ list[Mobject]
+ A list of mobjects that have points.
+
+ Examples
+ --------
+ ::
+
+ >>> from manim import Square, Rectangle, VGroup, Group, Mobject, VMobject
+ >>> s, r, m, v = Square(), Rectangle(), Mobject(), VMobject()
+ >>> vg = VGroup(s, r)
+ >>> gr = Group(vg, m, v)
+ >>> gr.family_members_with_points()
+ [Square, Rectangle]
+
+ See also
+ --------
+ :meth:`~.Mobject.get_family`
+
+ """
return [m for m in self.get_family() if m.get_num_points() > 0]
def arrange(