Python wrapper around the C++ ``LhaID`` identifier.
``LhaID`` represents an identifier as an *ordered* sequence of integer parts.
This allows representing both:
- simple IDs (single part), e.g. a PDG-like code, and
- multi-part IDs (several parts), e.g. (block, row, column).
The canonical string representation joins the integer parts with underscores:
- ``[511]`` -> ``"511"``
- ``[5, 2]`` -> ``"5_2"``
- ``[321, 1, 3]`` -> ``"321_1_3"``
Notes:
- Hashing and comparisons are delegated to the underlying C++ object.
- Converting to ``int`` keeps **only the first part** (potentially losing
information for multi-part IDs), mirroring the C++ behavior.
Definition at line 7 of file LhaID.py.
| pyhyperiso.core.Common.LhaID.LhaID.__init__ |
( |
|
self, |
|
|
*Union[int, str, List[int], common.LhaID] |
args |
|
) |
| |
Create a ``LhaID`` from common Python representations.
This wrapper mirrors the C++ constructors which accept:
- a variadic list of integral sub-IDs,
- an underscore-separated string,
- a vector/list of integers,
- or an existing ``LhaID`` object.
Args:
*args: One of the following forms:
- ``LhaID(cpp_id)``
Where ``cpp_id`` is an existing ``common.LhaID`` instance.
- ``LhaID(n)``
Where ``n`` is a single integer sub-ID.
- ``LhaID("1_2_3")``
Underscore-separated sub-IDs.
- ``LhaID([1, 2, 3])``
List of sub-IDs.
- ``LhaID(1, 2, 3)``
Multiple positional integer sub-IDs.
Raises:
TypeError: If the provided argument types are not supported.
Examples:
>>> LhaID(511).to_string()
'511'
>>> LhaID("5_2").get_parts()
[5, 2]
>>> LhaID(321, 1, 3).to_string()
'321_1_3'
Definition at line 27 of file LhaID.py.