ParameterCard
symbolica.community.hepkit Class
ParameterCard()Mutable external parameter values for a particle model.
A parameter card can be initialized from a model, edited by parameter name, serialized as JSON, and atomically applied to a model copy.
Examples
from symbolica import S, E
from symbolica.community import hepkit as hep
model = hep.Model.standard_model()
card = model.default_parameter_card()
card.set("MM", 0.105658, 0.0)
shifted_model = model.with_parameter_card(card)Constructor
#Create an empty parameter card.
Examples
Using the setup in the ParameterCard class example:
card = hep.ParameterCard()Member details
from_json
Static method#from_json(json: str) -> ParameterCardParse a parameter card from its JSON representation.
Examples
Using the setup in the ParameterCard class example:
card = hep.ParameterCard.from_json('{"mass": [1.0, 0.0]}')Parameters
| Name | Type | Default | Description |
|---|---|---|---|
json | str | — | Serialized parameter-card object. |
from_path
Static method#from_path(path: str | os.PathLike | pathlib.Path) -> ParameterCard Load a parameter card from a JSON file.
Examples
Using the setup in the ParameterCard class example:
from pathlib import Path
from tempfile import TemporaryDirectory
with TemporaryDirectory() as directory:
path = Path(directory) / "parameters.json"
path.write_text(card.to_json())
restored = hep.ParameterCard.from_path(path)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
path | str | os. | — | Path to the JSON parameter card. |
get
Method#get(name: str) -> Optional[tuple[float, float]] Return a parameter's complex value, or None when it is absent.
Examples
Using the setup in the ParameterCard class example:
card.get("mass")Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | str | — | Parameter name to look up. |
set
Method#set(name: str, real: float, imaginary: float = 0.0) -> None Store a complex parameter value.
Examples
Using the setup in the ParameterCard class example:
card.set("mass", 1.0)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | str | — | Parameter name to store. |
real | float | — | Real component of the value. |
imaginary | float | 0.0 | Imaginary component of the value. |
remove
Method#remove(name: str) -> Optional[tuple[float, float]] Remove and return a parameter value, if present.
Examples
Using the setup in the ParameterCard class example:
card.remove("mass")Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | str | — | Parameter name to remove. |
items
Method#items() -> list[tuple[str, tuple[float, float]]] Return all parameter-card entries.
Examples
Using the setup in the ParameterCard class example:
card.items()to_json
Method#to_json(pretty: bool = True) -> strSerialize the parameter card as JSON.
Examples
Using the setup in the ParameterCard class example:
card.to_json(pretty=False)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
pretty | bool | True | Indent the output when true. |
write_json
Method#write_json(path: str | os.PathLike | pathlib.Path) -> None Write the parameter card to a JSON file.
Examples
Using the setup in the ParameterCard class example:
card.write_json("parameters.json")Parameters
| Name | Type | Default | Description |
|---|---|---|---|
path | str | os. | — | Destination for the JSON parameter card. |
__len__
Method#__len__() -> intReturn the number of entries in the parameter card.
Examples
Using the setup in the ParameterCard class example:
number_of_external_inputs = len(model.default_parameter_card())View generated signature source: docs/api/python/feynkit-community.pyi:8714