FeynKit · latest
On this page

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) -> ParameterCard

Parse 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

NameTypeDefaultDescription
jsonstr—

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

NameTypeDefaultDescription
pathstr | os.PathLike | pathlib.Path—

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

NameTypeDefaultDescription
namestr—

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

NameTypeDefaultDescription
namestr—

Parameter name to store.

realfloat—

Real component of the value.

imaginaryfloat0.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

NameTypeDefaultDescription
namestr—

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) -> str

Serialize the parameter card as JSON.

Examples

Using the setup in the ParameterCard class example:

card.to_json(pretty=False)

Parameters

NameTypeDefaultDescription
prettyboolTrue

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

NameTypeDefaultDescription
pathstr | os.PathLike | pathlib.Path—

Destination for the JSON parameter card.

__len__

Method#
__len__() -> int

Return 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())