Exemplo n.º 1
0
    def to_index(ind):
        """ Returns a quantum number index after checking it

        If the index is bad, raises an IndexError

        Input:
            ind:
                Quantum number (Index or str)

        Output:
            An index
        """
        if isinstance(ind, str):
            ind = ind.encode("ascii")
            ind = lib.string2quantumnumbersindex(ind)
        else:
            ind = int(ind)

        if ind >= 0 and ind < lib.sizeQuantumNumbers():
            return ind
        else:
            raise IndexError("Out of bounds")
Exemplo n.º 2
0
 def size(self):
     """ Number of defined quantum numbers (constexpr Index) """
     return lib.sizeQuantumNumbers()