compare_values(expected, computed, label: str = None, *, atol: float = 1e-06, rtol: float = 1e-16, equal_nan: bool = False, passnone: bool = False, quiet: bool = False, return_message: bool = False, return_handler: Callable = None) → bool¶
Returns True if two floats or float arrays are element-wise equal within a tolerance.
expected (float or float array-like) – Reference value against which computed is compared.
computed (float or float array-like) – Input value to compare against expected.
atol (float, optional) – Absolute tolerance (see formula below).
label (str, optional) – Label for passed and error messages. Defaults to calling function name.
rtol (float, optional) – Relative tolerance (see formula below). By default set to zero so atol dominates.
equal_nan (bool, optional) – Passed to np.isclose. Compare NaN’s as equal.
passnone (bool, optional) – Return True when both expected and computed are None.
quiet (bool, optional) – Whether to log the return message.
return_message (bool, optional) – Whether to return tuple. See below.
allclose (bool) – Returns True if expected and computed are equal within tolerance; False otherwise.
message (str, optional) – When return_message=True, also return passed or error message.
- Other Parameters
return_handler (function, optional) – Function to control printing, logging, raising, and returning. Specialized interception for interfacing testing systems.
Akin to np.allclose.
For scalar float-comparable types and for arbitrary-dimension, np.ndarray-castable, uniform-type, float-comparable types. For mixed types, use
Sets rtol to zero to match expected Psi4 behaviour, otherwise measured as:
absolute(computed - expected) <= (atol + rtol * absolute(expected))