braintools.tree.shift

Contents

braintools.tree.shift#

braintools.tree.shift(tree1, x, is_leaf=<function is_quantity>)[source]#

Add a value to every leaf array in a PyTree.

Parameters:
  • tree1 (Quantity]) – Input PyTree.

  • x (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Value broadcast and added to each leaf of tree1.

  • is_leaf (Callable[[Any], bool] | None) – Predicate to treat a node as a leaf during traversal. Defaults to u.math.is_quantity.

Returns:

PyTree with each leaf shifted by x.

Return type:

PyTree

See also

add

Elementwise addition with a PyTree or value.

sub

Elementwise subtraction of PyTrees.