Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint NNX Module iter_* method docs in module.py #4447

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions flax/nnx/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ def sow(
setattr(self, name, variable_type(reduced_value))

def iter_modules(self) -> tp.Iterator[tuple[PathParts, Module]]:
"""Recursively iterates over all nested :class:`Module`'s of the current Module, including
the current Module.
"""Recursively iterates over all nested :class:`flax.nnx.Module`'s of the current
``Module``, including the current ``Module``.

``iter_modules`` creates a generator that yields the path and the Module instance, where
the path is a tuple of strings or integers representing the path to the Module from the
root Module.
``nnx.Module.iter_modules`` creates a generator that yields the path and the ``nnx.Module``
instance, where the path is a tuple of strings or integers representing the path to the
``nnx.Module`` from the root ``nnx.Module``.

Example::

Expand Down Expand Up @@ -224,13 +224,14 @@ def iter_modules(self) -> tp.Iterator[tuple[PathParts, Module]]:
yield path, value

def iter_children(self) -> tp.Iterator[tuple[Key, Module]]:
"""Iterates over all children :class:`Module`'s of the current Module. This
method is similar to :func:`iter_modules`, except it only iterates over the
immediate children, and does not recurse further down.

``iter_children`` creates a generator that yields the key and the Module instance,
where the key is a string representing the attribute name of the Module to access
the corresponding child Module.
"""Iterates over all children :class:`flax.nnx.Module`'s of the current
``Module``. This method is similar to :func:`flax.nnx.Module.iter_modules`,
except it only iterates over the immediate children, and does not recurse further
down.

``nnx.Module.iter_children`` creates a generator that yields the key and the
``nnx.Module`` instance, where the key is a string representing the attribute
name of the ``nnx.Module`` to access the corresponding child ``nnx.Module``.

Example::

Expand Down
Loading