triqs.operators.util.observables.check_backward_compat

triqs.operators.util.observables.check_backward_compat(fname, n_orb, orb_names)[source]

Validate and normalize the orbital count for backward compatibility.

Raises if the removed orb_names argument is supplied, and converts a list passed in place of n_orb into its length while emitting a UserWarning.

Parameters:
fnamestr

Name of the calling function, used in the warning message.

n_orbint or list

Number of orbitals. A list is accepted for backward compatibility and replaced by its length.

orb_namesobject

Removed argument retained for error reporting. Must be None; otherwise a RuntimeError is raised.

Returns:
int

The (normalized) number of orbitals.

Examples

>>> check_backward_compat('N_op', 5, None)
5
>>> check_backward_compat('N_op', ['s', 'p_x', 'p_y'], None)
3