FeynKit · latest
On this page

GenerationResult

symbolica.community.hepkit 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)

Member details

diagrams

Property · read-only#
diagrams: 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

Property · read-only#
groups: 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

Property · read-only#
report: GenerationReport

Return generation counts and completion status.

Examples

Using the setup in the GenerationResult class example:

assert result.report.completed

__len__

Method#
__len__() -> int

Return the number of retained diagrams.

Examples

Using the setup in the GenerationResult class example:

number_of_diagrams = len(result)

__getitem__

Method#
__getitem__(index: int) -> FeynmanDiagram

Return one retained diagram by generated-order index.

Examples

Using the setup in the GenerationResult class example:

first_diagram = result[0]

Parameters

NameTypeDefaultDescription
indexint—

Zero-based index; negative indices count from the end.

__iter__

Method#
__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]

__repr__

Method#
__repr__() -> str

Return a concise summary of the retained diagrams and groups.

Examples

Using the setup in the GenerationResult class example:

print(result)

render

Method#
render(*, config: Optional[RenderSettings] = None, style: Optional[DiagramStyle] = None, max_diagrams: Optional[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

NameTypeDefaultDescription
configOptional[RenderSettings]None

Layout, label and drawing settings shared by the displayed diagrams.

styleOptional[DiagramStyle]None

Particle, momentum and physical index presentation.

max_diagramsOptional[int]6

Maximum displayed diagrams (default 6); None includes all, 0 none.

_repr_mimebundle_

Method#
_repr_mimebundle_(include: Optional[Sequence[str]] = None, exclude: Optional[Sequence[str]] = None) -> 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

NameTypeDefaultDescription
includeOptional[Sequence[str]]None

MIME types requested by the frontend; None allows all available types.

excludeOptional[Sequence[str]]None

MIME types omitted from the frontend response.

_mime_

Method#
_mime_() -> 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_pretty_

Method#
_repr_pretty_(pretty: Any, cycle: 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

NameTypeDefaultDescription
prettyAny—

The IPython pretty-printer object.

cyclebool—

Whether this object is part of a recursive formatting cycle.