Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
pyhyperiso.core.Common.LhaID.LhaID Class Reference

Public Member Functions

 __init__ (self, *Union[int, str, List[int], common.LhaID] args)
 
 to_cpp (self)
 
 to_string (self)
 
 get_parts (self)
 
 __int__ (self)
 
 __eq__ (self, other)
 
 __repr__ (self)
 
 __hash__ (self)
 

Protected Attributes

 _cpp_obj
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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.

Member Function Documentation

◆ __eq__()

pyhyperiso.core.Common.LhaID.LhaID.__eq__ (   self,
  other 
)
Check equality with another ``LhaID``.

Args:
    other (LhaID): Another wrapped identifier.

Returns:
    bool: ``True`` if both wrap equal C++ ``LhaID`` values.

Definition at line 120 of file LhaID.py.

◆ __hash__()

pyhyperiso.core.Common.LhaID.LhaID.__hash__ (   self)
Make the object usable as a dict key / set element.

Returns:
    int: Hash based on the identifier parts.

Definition at line 139 of file LhaID.py.

◆ __int__()

pyhyperiso.core.Common.LhaID.LhaID.__int__ (   self)
Convert the identifier to a Python ``int``.

This is intended for *trivial* (single-part) IDs. If the underlying ID
contains multiple parts, only the **first** part is returned (the C++
implementation may emit a warning).

Returns:
    int: The first part of the identifier.

Raises:
    ValueError: If the identifier has no parts (depends on the C++ binding).

Definition at line 105 of file LhaID.py.

◆ __repr__()

pyhyperiso.core.Common.LhaID.LhaID.__repr__ (   self)
Return a debug representation.

Returns:
    str: Debug-style string such as ``"LhaID(1_2_3)"``.

Definition at line 131 of file LhaID.py.

◆ get_parts()

pyhyperiso.core.Common.LhaID.LhaID.get_parts (   self)
Return the ordered list of integer parts.

Returns:
    List[int]: The sub-IDs making up this identifier.

Definition at line 97 of file LhaID.py.

◆ to_cpp()

pyhyperiso.core.Common.LhaID.LhaID.to_cpp (   self)
Return the underlying bound C++ object.

Returns:
    common.LhaID: The wrapped pybind11 C++ instance.

Definition at line 80 of file LhaID.py.

◆ to_string()

pyhyperiso.core.Common.LhaID.LhaID.to_string (   self)
Return the canonical underscore-joined string representation.

Returns:
    str: Canonical string form (e.g. ``"1_2_3"``). If the identifier has
    no parts, the C++ implementation typically returns an empty string.

Definition at line 88 of file LhaID.py.

Member Data Documentation

◆ _cpp_obj

pyhyperiso.core.Common.LhaID.LhaID._cpp_obj
protected

Definition at line 68 of file LhaID.py.


The documentation for this class was generated from the following file: