Skip to content

Commit c53ac55

Browse files
irvanalhaq9pre-commit-ci[bot]chopan050
authored
Add docstring to :meth:Mobject.family_members_with_points (#4128)
* Add example to family_members_with_points method in Mobject * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add the word 'recursively' to clarify the method description * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Improve the sentence of method description * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Improve the method description * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Adding brackets * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add 'See also' section * Update manim/mobject/mobject.py Co-authored-by: Francisco Manríquez Novoa <[email protected]> * chenge list to list[Mobject] --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Francisco Manríquez Novoa <[email protected]>
1 parent 7f6743e commit c53ac55

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

manim/mobject/mobject.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2319,7 +2319,7 @@ def get_family(self, recurse: bool = True) -> list[Self]:
23192319
23202320
Returns
23212321
-------
2322-
list
2322+
list[Mobject]
23232323
A list of mobjects in the family of the given mobject.
23242324
23252325
Examples
@@ -2333,12 +2333,39 @@ def get_family(self, recurse: bool = True) -> list[Self]:
23332333
>>> gr.get_family()
23342334
[Group, VGroup(Square, Rectangle), Square, Rectangle, Mobject, VMobject]
23352335
2336+
See also
2337+
--------
2338+
:meth:`~.Mobject.family_members_with_points`, :meth:`~.Mobject.align_data`
2339+
23362340
"""
23372341
sub_families = [x.get_family() for x in self.submobjects]
23382342
all_mobjects = [self] + list(it.chain(*sub_families))
23392343
return remove_list_redundancies(all_mobjects)
23402344

23412345
def family_members_with_points(self) -> list[Self]:
2346+
"""Filters the list of family members (generated by :meth:`.get_family`) to include only mobjects with points.
2347+
2348+
Returns
2349+
-------
2350+
list[Mobject]
2351+
A list of mobjects that have points.
2352+
2353+
Examples
2354+
--------
2355+
::
2356+
2357+
>>> from manim import Square, Rectangle, VGroup, Group, Mobject, VMobject
2358+
>>> s, r, m, v = Square(), Rectangle(), Mobject(), VMobject()
2359+
>>> vg = VGroup(s, r)
2360+
>>> gr = Group(vg, m, v)
2361+
>>> gr.family_members_with_points()
2362+
[Square, Rectangle]
2363+
2364+
See also
2365+
--------
2366+
:meth:`~.Mobject.get_family`
2367+
2368+
"""
23422369
return [m for m in self.get_family() if m.get_num_points() > 0]
23432370

23442371
def arrange(

0 commit comments

Comments
 (0)