Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
ParameterShifter.py
Go to the documentation of this file.
1"""Mutable parameter shifter for nuisance/scan workflows."""
2
3from __future__ import annotations
4
5from typing import Union
6
7from pyhyperiso.phyperiso.pyhyperiso.core import ParameterShifter as _CppParameterShifter
8from pyhyperiso.core.Common.ParamId import ParamId
9from pyhyperiso.core.Core.Parameter import ParameterMode
10from pyhyperiso.core.Math.scalar import Scalar, _to_scalar
11
12
14 """Python wrapper around the C++ ``ParameterShifter``.
15
16 This class exposes the same Python surface as ``ParameterSetter`` but is
17 backed by the C++ shifter object. It is useful for workflows that treat
18 parameter changes as shifts rather than direct value replacement in the C++
19 parameter layer.
20 """
21
22 def __init__(self) -> None:
23 """Create a shifter bound to the current C++ parameter storage."""
24 self._cpp_obj = _CppParameterShifter()
25
26 def mutate(self, pid: ParamId, value: Union[float, complex, Scalar]) -> None:
27 """Apply a new shifted value to a parameter.
28
29 Args:
30 pid: Parameter to shift.
31 value: Shifted value. Numeric inputs are converted to ``Scalar``.
32 """
33 self._cpp_obj.mutate(pid._cpp_obj, _to_scalar(value)._cpp_obj)
34
35 def change_mode(self, pid: ParamId, mode: ParameterMode) -> None:
36 """Change a parameter update mode.
37
38 Args:
39 pid: Parameter to update.
40 mode: New mode, such as ``ParameterMode.FIXED`` or
41 ``ParameterMode.SHIFTABLE``.
42 """
43 self._cpp_obj.change_mode(pid._cpp_obj, mode.value)
44
45
46__all__ = ["ParameterShifter"]
None mutate(self, ParamId pid, Union[float, complex, Scalar] value)
None change_mode(self, ParamId pid, ParameterMode mode)