braintools.tree.sub

Contents

braintools.tree.sub#

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

Elementwise subtraction of two PyTrees.

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

  • tree2 (Quantity]) – Subtrahend PyTree. Must share the same PyTree structure as 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 where each leaf is tree1 - tree2 elementwise.

Return type:

PyTree

See also

add

Elementwise addition of PyTrees.

mul

Elementwise multiplication.