triqs.gfs.tools.map_block

triqs.gfs.tools.map_block(fun, G)[source]

Apply fun to every block of G and return the result.

Parameters:
funcallable

Function with signature fun(g) -> Gf (or returning any object — see “Returns” below).

GBlockGf or Block2Gf

Container whose blocks fun is applied to.

Returns:
BlockGf or Block2Gf or list
  • If fun returns Gf instances, the result is a new BlockGf / Block2Gf with the same block structure as G.

  • Otherwise the per-block results are returned as a plain list (or list of lists for Block2Gf).

Raises:
Exception

If G is neither a BlockGf nor a Block2Gf.

Examples

>>> from triqs.gfs import map_block, inverse
>>> G_inv = map_block(inverse, G_block)