ParameterCard

Symbolica documentation for getting started, symbolic expressions, numerical evaluation, pattern matching, and APIs in Python and Rust.

ParameterCard

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)

Methods

Name Description
__len__ Return the number of entries in the parameter card.
__new__ Create an empty parameter card.
from_json Parse a parameter card from its JSON representation.
from_path Load a parameter card from a JSON file.
get Return a parameter’s complex value, or None when it is absent.
items Return all parameter-card entries.
remove Remove and return a parameter value, if present.
set Store a complex parameter value.
to_json Serialize the parameter card as JSON.
write_json Write the parameter card to a JSON file.

__len__

ParameterCard.__len__() -> builtins.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())

__new__

ParameterCard.__new__() -> ParameterCard

Create an empty parameter card.

Examples

Using the setup in the ParameterCard class example:

card = hep.ParameterCard()

from_json

ParameterCard.from_json(json: builtins.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

  • json (str) Serialized parameter-card object.

from_path

ParameterCard.from_path(path: builtins.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

  • path (str or os.PathLike) Path to the JSON parameter card.

get

ParameterCard.get(name: builtins.str) -> typing.Optional[tuple[builtins.float, builtins.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 (str) Parameter name to look up.

items

ParameterCard.items() -> builtins.list[tuple[builtins.str, tuple[builtins.float, builtins.float]]]

Return all parameter-card entries.

Examples

Using the setup in the ParameterCard class example:

card.items()

remove

ParameterCard.remove(name: builtins.str) -> typing.Optional[tuple[builtins.float, builtins.float]]

Remove and return a parameter value, if present.

Examples

Using the setup in the ParameterCard class example:

card.remove("mass")

Parameters

  • name (str) Parameter name to remove.

set

ParameterCard.set(name: builtins.str, real: builtins.float, imaginary: builtins.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 (str) Parameter name to store.
  • real (float) Real component of the value.
  • imaginary (float) Imaginary component of the value.

to_json

ParameterCard.to_json(pretty: builtins.bool = True) -> builtins.str

Serialize the parameter card as JSON.

Examples

Using the setup in the ParameterCard class example:

card.to_json(pretty=False)

Parameters

  • pretty (bool) Indent the output when true.

write_json

ParameterCard.write_json(path: builtins.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

  • path (str or os.PathLike) Destination for the JSON parameter card.