FeynKit · latest
On this page

ModelFunction

symbolica.community.hepkit Class

ModelFunction()

A named helper function used by model expressions.

Functions expose their formal arguments and, when available, a symbolic implementation that an evaluator can use during parameter recomputation.

Examples

from symbolica import S, E
from symbolica.community import hepkit as hep
model = hep.Model.standard_model()
functions = {function.name: function.arguments for function in model.functions}

Member details

symbol

Property · read-only#
symbol: Expression

Return the symbolic reference used by this model's expressions. This preserves the parameter or function identity without substituting its defining expression or numerical value.

Examples

from symbolica.community import hepkit as hep
model = hep.Model.standard_model()
import json
definition = json.loads(model.to_json())
definition["functions"] = [{"name": "square", "arguments": ["x"], "expression": "x^2"}]
custom = hep.Model.from_json(json.dumps(definition))
reference = custom.function("square").symbol

name

Property · read-only#
name: str

Return the function name.

Examples

Using the setup in the ModelFunction class example:

names = [function.name for function in model.functions]

arguments

Property · read-only#
arguments: list[str]

Return the ordered argument names.

Examples

Using the setup in the ModelFunction class example:

arguments_by_name = {function.name: function.arguments for function in model.functions}

expression

Property · read-only#
expression: Optional[Expression]

Return the function body, when one is defined by the model.

Examples

Using the setup in the ModelFunction class example:

implementations = {function.name: function.expression for function in model.functions}

__repr__

Method#
__repr__() -> str

Summarize the defining data as well as the function name.

Examples

Using the setup in the ModelFunction class example:

summaries = [repr(function) for function in model.functions]

_repr_html_

Method#
_repr_html_() -> str

Display the model member's physical data and defining expressions.

Examples

Using the setup in the ModelFunction class example:

from IPython.display import display
display(model.functions)

_repr_pretty_

Method#
_repr_pretty_(pretty: Any, cycle: bool) -> None

Write the complete text summary to an IPython pretty printer.

Examples

Using the setup in the ModelFunction class example:

from IPython.lib.pretty import pretty
text = pretty(model.functions)

Parameters

NameTypeDefaultDescription
prettyAny—

IPython pretty printer receiving the text.

cyclebool—

Whether the object occurs recursively in the current display.