Skip to content

GenerationResult

Symbolica documentation for getting started, symbolic expressions, numerical evaluation, pattern matching, and APIs in Python and Rust.

GenerationResult

class GenerationResult

Feynman diagrams and diagnostics produced for one process.

The result retains generated diagrams in deterministic order and may also contain numerator-equivalence groups for efficient downstream evaluation.

Examples

from symbolica import S, E
from symbolica.community import hepkit as hep
model = hep.Model.phi4()
process = model.process(["phi", "phi"], ["phi", "phi"])
result = process.generate_diagrams(loops=1)
diagram = result.diagrams[0]
diagrams = result.diagrams
assert result.report.retained_count == len(diagrams)

Attributes

Name Description
diagrams Return every retained diagram in generated order.
groups Return the numerator groups in deterministic master-index order.
report Return generation counts and completion status.

diagrams

GenerationResult.diagrams: builtins.list[FeynmanDiagram]

Return every retained diagram in generated order.

Examples

Using the setup in the GenerationResult class example:

numerators = [diagram.numerator_expression() for diagram in result.diagrams]

groups

GenerationResult.groups: builtins.list[DiagramGroup]

Return the numerator groups in deterministic master-index order.

Examples

Using the setup in the GenerationResult class example:

masters = [result.diagrams[group.master] for group in result.groups]

report

GenerationResult.report: GenerationReport

Return generation counts and completion status.

Examples

Using the setup in the GenerationResult class example:

assert result.report.completed

Methods

Name Description
__getitem__ Return one retained diagram by generated-order index.
__iter__ Iterate over retained diagrams in deterministic generated order.
__len__ Return the number of retained diagrams.
__repr__ Return a concise summary of the retained diagrams and groups.
_mime_ Return Marimo MIME data with static output and an optional live widget.
_repr_mimebundle_ Return widget MIME data for the compact generation-result explorer.
_repr_pretty_ Write a concise result summary to an IPython pretty printer.
render Render a thumbnail strip and one shared interactive diagram viewer

__getitem__

GenerationResult.__getitem__(index: builtins.int) -> FeynmanDiagram

Return one retained diagram by generated-order index.

Examples

Using the setup in the GenerationResult class example:

first_diagram = result[0]

Parameters

  • index (int) Zero-based index; negative indices count from the end.

__iter__

GenerationResult.__iter__() -> collections.abc.Iterator[FeynmanDiagram]

Iterate over retained diagrams in deterministic generated order.

Examples

Using the setup in the GenerationResult class example:

one_loop = [diagram for diagram in result if diagram.loop_count == 1]

__len__

GenerationResult.__len__() -> builtins.int

Return the number of retained diagrams.

Examples

Using the setup in the GenerationResult class example:

number_of_diagrams = len(result)

__repr__

GenerationResult.__repr__() -> builtins.str

Return a concise summary of the retained diagrams and groups.

Examples

Using the setup in the GenerationResult class example:

print(result)

_mime_

GenerationResult._mime_() -> typing.Any

Return Marimo MIME data with static output and an optional live widget.

Examples

Using the setup in the GenerationResult class example:

view = result.render(max_diagrams=None)
view  # static output is immediate; an optional widget refines label sizes
snapshot = view.measured(browser="chromium")

_repr_mimebundle_

GenerationResult._repr_mimebundle_(
    include: typing.Optional[typing.Sequence[builtins.str]] = None,
    exclude: typing.Optional[typing.Sequence[builtins.str]] = None,
) -> typing.Any

Return widget MIME data for the compact generation-result explorer.

Examples

Using the setup in the GenerationResult class example:

view = result.render()
view  # static output is immediate; an optional widget refines label sizes
snapshot = view.measured(browser="chromium")

Parameters

  • include (list[str] or None, optional) MIME types requested by the frontend; None allows all available types.
  • exclude (list[str] or None, optional) MIME types omitted from the frontend response.

_repr_pretty_

GenerationResult._repr_pretty_(pretty: typing.Any, cycle: builtins.bool) -> None

Write a concise result summary to an IPython pretty printer.

Examples

Using the setup in the GenerationResult class example:

from IPython.lib.pretty import pretty
text = pretty(result)

Parameters

  • pretty (object) The IPython pretty-printer object.
  • cycle (bool) Whether this object is part of a recursive formatting cycle.

render

GenerationResult.render(
    *,
    config: typing.Optional[RenderSettings] = None,
    style: typing.Optional[DiagramStyle] = None,
    max_diagrams: typing.Optional[builtins.int] = 6,
) -> DiagramView

Render a thumbnail strip and one shared interactive diagram viewer.

The view measures labels when displayed. By default it includes six diagrams; max_diagrams=None includes the complete collection.

Examples

Using the setup in the GenerationResult class example:

view = result.render(max_diagrams=None)
view
snapshot = view.measured(browser="chromium")

Parameters

  • config (RenderSettings or None, optional) Layout, label and drawing settings shared by the displayed diagrams.
  • style (DiagramStyle or None, optional) Particle, momentum and physical index presentation.
  • max_diagrams (int or None, optional) Maximum displayed diagrams (default 6); None includes all, 0 none.