Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
MartyAdapter.py
Go to the documentation of this file.
1"""Python accessors for MARTY-related configuration."""
2
3from __future__ import annotations
4
5from enum import Enum
6from typing import Optional
7
8from pyhyperiso.phyperiso.pyhyperiso.core import MartyAdapter as _CppMartyAdapter
9from pyhyperiso.phyperiso.pyhyperiso.core import MartyPath as _CppMartyPath
10
11
12class MartyPath(Enum):
13 """MARTY path keys exposed by the C++ runtime.
14
15 Attributes:
16 MODEL_FILE: Path to the configured MARTY model file.
17 TEMPLATE_DIR: Read-only MARTY template directory.
18 PARAM_MAPPING_DIR: Read-only directory containing MARTY/Hyperiso mappings.
19 SM_MAPPING_FILE: Read-only SM mapping JSON.
20 BSM_MAPPING_FILE: Optional user-provided BSM mapping JSON.
21 MARTY_TEMP_DIR: Writable MARTY generated-code/cache directory.
22 """
23
24 MODEL_FILE = _CppMartyPath.MODEL_FILE
25 TEMPLATE_DIR = _CppMartyPath.TEMPLATE_DIR
26 PARAM_MAPPING_DIR = _CppMartyPath.PARAM_MAPPING_DIR
27 SM_MAPPING_FILE = _CppMartyPath.SM_MAPPING_FILE
28 BSM_MAPPING_FILE = _CppMartyPath.BSM_MAPPING_FILE
29 MARTY_TEMP_DIR = _CppMartyPath.MARTY_TEMP_DIR
30
31
33 """Inspect MARTY paths and flags used by Hyperiso.
34
35 This adapter is read-only from Python. It is typically useful after
36 ``HyperisoMaster.init(...)`` when debugging which MARTY model, mappings,
37 templates and writable cache directory were selected.
38 """
39
40 def __init__(self) -> None:
41 """Create an adapter bound to the current C++ MARTY configuration."""
42 self._cpp_obj = _CppMartyAdapter()
43
44 def get_path(self, path_kind: MartyPath) -> str:
45 """Return a required MARTY path by kind."""
46 return str(self._cpp_obj.get_path(path_kind.value))
47
48 def get_optional_path(self, path_kind: MartyPath) -> Optional[str]:
49 """Return an optional MARTY path, or ``None`` when it is not configured."""
50 value = self._cpp_obj.get_optional_path(path_kind.value)
51 return None if value is None else str(value)
52
53 def check_flag(self, flag) -> bool:
54 """Return the value of a MARTY-related C++ flag."""
55 return bool(self._cpp_obj.check_flag(flag))
56
57 def get_model_name(self) -> str:
58 """Return the configured MARTY model name."""
59 return str(self._cpp_obj.get_marty_model_name())
60
61 def __repr__(self) -> str:
62 """Return a compact representation including the model name."""
63 return f"<PyMartyAdapter model='{self.get_model_name()}'>"
64
65
66__all__ = ["MartyAdapter", "MartyPath"]
str get_path(self, MartyPath path_kind)
Optional[str] get_optional_path(self, MartyPath path_kind)