qspec logo qspec logo

A physics toolbox for laser spectroscopy.

Static Badge Static Badge Static Badge

Static Badge Static Badge

© 2026 Patrick Müller. All rights reserved.

qspec. quant  (  value  )[source]

Convert a string or a number to a floating-point quantum number, if possible. Adding and subtracting quantum numbers returns a new quantum number. For all other algebraic operations or if different data types are involved, quantum numbers behave like floats.

Parameters:
valueSupportsFloat | str

A (half-)integer number or a string such as "3/2".

Attributes:
pint

The numerator of the quantum number, e.g. 3 for 3/2.

qint

The denominator of the quantum number, 1 for integers and 2 for half-integers.

sRational

The quantum number as a sympy Rational.

Raises:
ValueError

If value is not a (half-)integer number.