Filters
parax.remove(pytree, condition, *, stop_if=None)
Removes nodes from a PyTree that match a given condition.
Replaces matching nodes with None. Halts traversal at matching nodes,
as well as any nodes matching stop_if.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pytree
|
PyTree
|
The input PyTree to filter. |
required |
condition
|
Callable[[Any], bool]
|
A function that evaluates to True for nodes that should be removed. |
required |
stop_if
|
Callable[[Any], bool]
|
A function that evaluates to True
for leaf nodes in addition to |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A copy of the PyTree with the matched nodes replaced by None. |
Source code in parax/filters.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
parax.is_constant(x)
Returns True if x is an instance of parax.AbstractConstant.
Useful as is_leaf when partitioning a model to freeze standard parameters.
Source code in parax/constants.py
35 36 37 38 39 40 41 | |
parax.is_annotated(x)
Returns True if x is an instance of parax.AbstractAnnotated
(i.e. has metadata).
Source code in parax/annotation.py
28 29 30 31 32 33 | |
parax.is_variable(x)
Returns True if x is an instance of parax.AbstractVariable.
Source code in parax/variables.py
120 121 122 123 124 | |
parax.is_param(x)
Returns True if x is an instance of parax.AbstractVariable
or returns True for eqx.is_inexact_array.
Source code in parax/variables.py
127 128 129 130 131 132 | |
parax.is_unwrappable(x)
Checks if a given object is an unwrappable node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Any
|
The object to check. |
required |
Returns:
| Type | Description |
|---|---|
TypeGuard[AbstractUnwrappable]
|
True if |
Source code in parax/wrappers.py
47 48 49 50 51 52 53 54 55 56 | |
parax.is_wrappable(x)
Checks if a given object is a wrappable node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Any
|
The object to check. |
required |
Returns:
| Type | Description |
|---|---|
TypeGuard[AbstractWrappable]
|
True if |
Source code in parax/wrappers.py
209 210 211 212 213 214 215 216 217 218 | |
parax.is_bounded(x)
Returns True if x is an instance of parax.AbstractBounded.
Source code in parax/bounds.py
27 28 29 30 31 | |
parax.is_probabilistic(x)
Returns True if x is an instance of parax.AbstractProbabilistic.
Source code in parax/probability.py
38 39 40 41 42 | |
parax.is_constraint(x)
Returns True if x is an instance of parax.AbstractConstraint.
Source code in parax/constraints.py
93 94 95 96 97 | |
parax.is_distribution(x)
Returns True if x is an instance of distreqx.AbstractDistribution.
Source code in parax/filters.py
14 15 16 17 18 | |
parax.is_bijector(x)
Returns True if x is an instance of distreqx.AbstractBijector.
Source code in parax/filters.py
21 22 23 24 25 | |