Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
DependantBlockInfoProvider.py
Go to the documentation of this file.
1"""Python wrapper for dependent-block graph introspection.
2
3This module exposes a high-level Python facade over the C++
4``DependantBlockInfoProvider``. It lets Python workflows inspect whether a
5block is dependent, which blocks it depends on, and which blocks depend on it.
6
7The Hyperiso core must be initialized before calling these methods, typically
8through ``HyperisoMaster.init(...)``.
9"""
10
11from typing import List, Optional
12
13from pyhyperiso.phyperiso.pyhyperiso.core import (
14 DependantBlockInfoProvider as _CppDependantBlockInfoProvider,
15)
16from pyhyperiso.core.Common.GeneralEnum import ParameterType
17
18
20 """Inspect block-level dependencies from Python.
21
22 Args:
23 cpp_obj: Optional already-bound C++ provider. When omitted, a new C++
24 ``DependantBlockInfoProvider`` is created.
25
26 Example:
27 >>> provider = DependantBlockInfoProvider()
28 >>> provider.is_dependent_block(ParameterType.SM, "EW")
29 True
30 >>> provider.get_source_blocks(ParameterType.SM, "EW")
31 ['QCD', 'SMINPUTS']
32 """
33
34 def __init__(self, cpp_obj: Optional[_CppDependantBlockInfoProvider] = None):
35 """Create the Python wrapper around the C++ provider."""
36 self._cpp_obj = cpp_obj or _CppDependantBlockInfoProvider()
37
38 def is_dependent_block(self, parameter_type: ParameterType, block_name: str) -> bool:
39 """Return whether ``block_name`` is a dependent block.
40
41 Args:
42 parameter_type: Parameter namespace containing the block.
43 block_name: Name or alias of the block to inspect.
44
45 Returns:
46 bool: ``True`` when the underlying C++ block is a dependent block.
47 """
48 return self._cpp_obj.is_dependent_block(parameter_type.value, block_name)
49
50 def get_source_blocks(self, parameter_type: ParameterType, block_name: str) -> List[str]:
51 """Return the direct upstream blocks used by ``block_name``.
52
53 This answers: "which blocks does this block depend on directly?"
54
55 Args:
56 parameter_type: Parameter namespace containing the block.
57 block_name: Name or alias of the block to inspect.
58
59 Returns:
60 list[str]: Sorted direct source block names.
61 """
62 return list(self._cpp_obj.get_source_blocks(parameter_type.value, block_name))
63
64 def get_dependent_blocks(self, parameter_type: ParameterType, block_name: str) -> List[str]:
65 """Return the direct blocks depending on ``block_name``.
66
67 This answers: "which blocks directly depend on this block?"
68
69 Args:
70 parameter_type: Parameter namespace containing the block.
71 block_name: Name or alias of the block to inspect.
72
73 Returns:
74 list[str]: Sorted direct dependent/downstream block names.
75 """
76 return list(self._cpp_obj.get_dependent_blocks(parameter_type.value, block_name))
77
78 def get_all_source_blocks(self, parameter_type: ParameterType, block_name: str) -> List[str]:
79 """Return all transitive upstream blocks used by ``block_name``.
80
81 Args:
82 parameter_type: Parameter namespace containing the block.
83 block_name: Name or alias of the block to inspect.
84
85 Returns:
86 list[str]: Sorted deduplicated source block names.
87 """
88 return list(self._cpp_obj.get_all_source_blocks(parameter_type.value, block_name))
89
90 def get_all_dependent_blocks(self, parameter_type: ParameterType, block_name: str) -> List[str]:
91 """Return all transitive blocks depending on ``block_name``.
92
93 Args:
94 parameter_type: Parameter namespace containing the block.
95 block_name: Name or alias of the block to inspect.
96
97 Returns:
98 list[str]: Sorted deduplicated dependent/downstream block names.
99 """
100 return list(self._cpp_obj.get_all_dependent_blocks(parameter_type.value, block_name))
101
102
103__all__ = ["DependantBlockInfoProvider"]
bool is_dependent_block(self, ParameterType parameter_type, str block_name)
List[str] get_all_dependent_blocks(self, ParameterType parameter_type, str block_name)
List[str] get_all_source_blocks(self, ParameterType parameter_type, str block_name)
__init__(self, Optional[_CppDependantBlockInfoProvider] cpp_obj=None)
List[str] get_dependent_blocks(self, ParameterType parameter_type, str block_name)
List[str] get_source_blocks(self, ParameterType parameter_type, str block_name)