Skip to content

Commit

Permalink
fixup docs for Composite.iterChildren
Browse files Browse the repository at this point in the history
  • Loading branch information
drewj-tp committed Dec 11, 2024
1 parent 5399d69 commit 0bb6bc1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions armi/reactor/composites.py
Original file line number Diff line number Diff line change
Expand Up @@ -2637,22 +2637,27 @@ def iterChildren(
predicate: Optional[Callable[["Composite"], bool]] = None,
) -> Iterator["Composite"]:
"""Iterate over children objects of this composite.
Parameters
----------
deep : bool, optional
If true, traverse the entire composite tree. Otherwise, go as far as ``generationNum``.
generationNum: int, optional
predicate: f(Composite) -> bool, optional,
Produce composites at this depth. A depth of ``1`` includes children of ``self``, ``2``
is children of children, and so on.
predicate: f(Composite) -> bool, optional
Function to check on a composite before producing it. All items in the iteration
will pass this check.
Returns
-------
iterator of Composite
See Also
--------
:meth:`getChildren` produces a list for situations where you need to perform
multiple iterations or do list operations (append, indexing, sorting, containment, etc.)
Composites are naturally iterable. The following are identical::
>>> for child in c.getChildren():
Expand All @@ -2663,7 +2668,7 @@ def iterChildren(
... pass
If you do not need any depth-traversal, natural iteration should be sufficient.
The :func:`filter` command may be sufficient if you do not wish to pass a predicate. The following
are identical::
>>> checker = lambda c: len(c.name) % 3
Expand All @@ -2675,7 +2680,7 @@ def iterChildren(
... pass
If you're going to be doing traversal beyond the first generation, this method will help you.
"""
if deep and generationNum > 1:
raise RuntimeError(
Expand Down

0 comments on commit 0bb6bc1

Please sign in to comment.