Skip to content

Commit 8f919b1

Browse files
Add docstring to :meth:.Mobject.get_family (#4127)
* Add example to get_family method in Mobject * [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 6ca08fd commit 8f919b1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

manim/mobject/mobject.py

+25
Original file line numberDiff line numberDiff line change
@@ -2309,6 +2309,31 @@ def split(self) -> list[Self]:
23092309
return result + self.submobjects
23102310

23112311
def get_family(self, recurse: bool = True) -> list[Self]:
2312+
"""Lists all mobjects in the hierarchy (family) of the given mobject,
2313+
including the mobject itself and all its submobjects recursively.
2314+
2315+
Parameters
2316+
----------
2317+
recurse
2318+
Just for consistency with get_family method in OpenGLMobject.
2319+
2320+
Returns
2321+
-------
2322+
list
2323+
A list of mobjects in the family of the given mobject.
2324+
2325+
Examples
2326+
--------
2327+
::
2328+
2329+
>>> from manim import Square, Rectangle, VGroup, Group, Mobject, VMobject
2330+
>>> s, r, m, v = Square(), Rectangle(), Mobject(), VMobject()
2331+
>>> vg = VGroup(s, r)
2332+
>>> gr = Group(vg, m, v)
2333+
>>> gr.get_family()
2334+
[Group, VGroup(Square, Rectangle), Square, Rectangle, Mobject, VMobject]
2335+
2336+
"""
23122337
sub_families = [x.get_family() for x in self.submobjects]
23132338
all_mobjects = [self] + list(it.chain(*sub_families))
23142339
return remove_list_redundancies(all_mobjects)

0 commit comments

Comments
 (0)