compare_recursive
- qcelemental.compare_recursive(expected, computed, label=None, *, atol=1e-06, rtol=1e-16, forgive=None, equal_phase=False, quiet=False, return_message=False, return_handler=None)[source]
Recursively compares nested structures such as dictionaries and lists.
- Parameters:
expected (Dict | BaseModel | BaseModel | ProtoModel) – Reference value against which computed is compared. Dict may be of any depth but should contain Plain Old Data.
computed (Dict | BaseModel | BaseModel | ProtoModel) – Input value to compare against expected. Dict may be of any depth but should contain Plain Old Data.
atol (float) – Absolute tolerance (see formula below).
label (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.
forgive (List[str]) – Keys in top level which may change between expected and computed without triggering failure.
equal_phase (bool | List) – Compare computed or its opposite as equal.
quiet (bool) – Whether to log the return message.
return_message (bool) – Whether to return tuple. See below.
return_handler (Callable)
- Returns:
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.
- Return type:
Notes
absolute(computed - expected) <= (atol + rtol * absolute(expected))