triqs.gfs.lazy_expressions.LazyExpr

class triqs.gfs.lazy_expressions.LazyExpr(*args)[source]

Bases: __aux

A node in a lazy expression tree.

Each node carries a tag and a list of childs. Tags are:

  • "T" — terminal; childs[0] is the wrapped value (descriptor, scalar, …).

  • "+", "-", "*", "/" — binary arithmetic; the two children are themselves LazyExpr nodes.

  • "F" — function application; childs[0] is a terminal wrapping the callable, the remaining children are its arguments.

Operator overloads on the parent __aux build these trees from Python expressions (a + b, f(a, b), …).

Parameters:
*args
  • Single argument — if it is a LazyExpr its tag and childs are aliased; otherwise the argument is wrapped as a terminal (tag = 'T').

  • Two or more arguments — first is interpreted as the tag, the rest as childs.

Attributes

tag

(str) Node kind.

childs

(list) Child nodes (or wrapped payload for terminals).

Methods

copy()

Shallow copy of this node (children are shared).

get_terminal()

Wrapped payload, or None if this node is not a leaf.

is_terminal()

Whether this node is a leaf node.

set_from(y)

In-place assignment: self is rewritten to match y.