qcelemental.testing.compare_values(expected, computed, label=None, *, atol=1e-06, rtol=1e-16, equal_nan=False, equal_phase=False, passnone=False, quiet=False, return_message=False, return_handler=None)[source]

Returns True if two floats or float arrays are element-wise equal within a tolerance.

  • expected (Union[float, List, ndarray]) – float or float array-like Reference value against which computed is compared.

  • computed (Union[float, List, ndarray]) – float or float array-like Input value to compare against expected.

  • atol (float) – Absolute tolerance (see formula below).

  • label (Optional[str]) – Label for passed and error messages. Defaults to calling function name.

  • rtol (float) – Relative tolerance (see formula below). By default set to zero so atol dominates.

  • equal_nan (bool) – Passed to numpy.isclose(). Compare NaN’s as equal.

  • equal_phase (bool) – Compare computed or its opposite as equal.

  • passnone (bool) – Return True when both expected and computed are None.

  • quiet (bool) – Whether to log the return message.

  • return_message (bool) – Whether to return tuple. See below.

  • return_handler (Optional[Callable]) – Function to control printing, logging, raising, and returning. Specialized interception for interfacing testing systems.

Return type

Union[bool, Tuple[bool, str]]


  • allclose (bool) – Returns True if expected and computed are equal within tolerance; False otherwise.

  • message (str) – When return_message=True, also return passed or error message.


  • Akin to numpy.allclose().

  • For scalar float-comparable types and for arbitrary-dimension, np.ndarray-castable, uniform-type, float-comparable types. For mixed types, use compare_recursive().

  • Sets rtol to zero to match expected Psi4 behaviour, otherwise measured as:

absolute(computed - expected) <= (atol + rtol * absolute(expected))