ModelFunction
ModelFunction
class ModelFunctionA 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}Attributes
| Name | Description |
|---|---|
arguments |
Return the ordered argument names. |
expression |
Return the function body, when one is defined by the model. |
name |
Return the function name. |
symbol |
Return the symbolic reference used by this model’s expressions |
arguments
ModelFunction.arguments: builtins.list[builtins.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
ModelFunction.expression: typing.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}name
ModelFunction.name: builtins.strReturn the function name.
Examples
Using the setup in the ModelFunction class example:
names = [function.name for function in model.functions]symbol
ModelFunction.symbol: ExpressionReturn 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").symbolMethods
| Name | Description |
|---|---|
__repr__ |
Summarize the defining data as well as the function name. |
_repr_html_ |
Display the model member’s physical data and defining expressions. |
_repr_pretty_ |
Write the complete text summary to an IPython pretty printer. |
__repr__
ModelFunction.__repr__() -> builtins.strSummarize 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_
ModelFunction._repr_html_() -> builtins.strDisplay 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_
ModelFunction._repr_pretty_(pretty: typing.Any, cycle: builtins.bool) -> NoneWrite 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
pretty(object) IPython pretty printer receiving the text.cycle(bool) Whether the object occurs recursively in the current display.