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

Update NNX State.state.merge method docs in statelib.py #4453

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
14 changes: 7 additions & 7 deletions flax/nnx/statelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@ def filter(
def merge(
state: tp.Mapping[K, V], /, *states: tp.Mapping[K, V]
) -> State[K, V]:
"""The inverse of :meth:`split() <flax.nnx.State.state.split>`.
"""The inverse of :func:`flax.nnx.State.state.split`.

``merge`` takes one or more ``State``'s and creates
a new ``State``.
``nnx.State.state.merge`` takes one or more :class:`flax.nnx.State`'s
and creates a new ``nnx.State``.

Example usage::

Expand All @@ -398,10 +398,10 @@ def merge(
>>> assert (model.linear.bias.value == jnp.array([1, 1, 1])).all()

Args:
state: A ``State`` object.
*states: Additional ``State`` objects.
state: A :class:`flax.nnx.State` object.
*states: Additional ``nnx.State`` objects.
Returns:
The merged ``State``.
The merged ``nnx.State``.
"""
if not states:
if isinstance(state, State):
Expand Down Expand Up @@ -492,4 +492,4 @@ def create_path_filters(state: State):
if isinstance(value, (variablelib.Variable, variablelib.VariableState)):
value = value.value
value_paths.setdefault(value, set()).add(path)
return {filterlib.PathIn(*value_paths[value]): value for value in value_paths}
return {filterlib.PathIn(*value_paths[value]): value for value in value_paths}
Loading