treeo.Merge
Mixin that adds a .merge()
method to the class.
merge(self, other, *rest, *, flatten_mode=None, ignore_static=False)
merge
is a wrapper over treeo.merge
that passes self
as the first argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
~A |
The pytree first to get the values to merge with. |
required |
*rest |
~A |
Additional pytree to perform the merge in order from left to right. |
() |
flatten_mode |
Union[treeo.tree.FlattenMode, str] |
Sets a new |
None |
ignore_static |
bool |
If |
False |
Returns:
Type | Description |
---|---|
~A |
A new pytree with the merged values. |
Source code in treeo/mixins.py
def merge(
self: A,
other: A,
*rest: A,
flatten_mode: tp.Union[api.FlattenMode, str, None] = None,
ignore_static: bool = False,
) -> A:
"""
`merge` is a wrapper over `treeo.merge` that passes `self` as the first argument.
Arguments:
other: The pytree first to get the values to merge with.
*rest: Additional pytree to perform the merge in order from left to right.
flatten_mode: Sets a new `FlattenMode` context for the operation, if `None` the current context is used. If the current flatten context is `None` and `flatten_mode` is not passed then `FlattenMode.all_fields` is used.
ignore_static: If `True`, bypasses static fields during the process and the statics fields for output are taken from the first input (`obj`).
Returns:
A new pytree with the merged values.
"""
return api.merge(
self,
other,
*rest,
flatten_mode=flatten_mode,
ignore_static=ignore_static,
)