qcelemental.testing.compare_recursive(expected: Union[Dict, pydantic.main.BaseModel, ProtoModel], computed: Union[Dict, pydantic.main.BaseModel, ProtoModel], label: str = None, *, atol: float = 1e-06, rtol: float = 1e-16, forgive: List[str] = None, quiet: bool = False, return_message: bool = False, return_handler: Callable = None) → bool[source]

Recursively compares nested structures such as dictionaries and lists.

  • expected (dict) – Reference value against which computed is compared. Dict may be of any depth but should contain Plain Old Data.

  • computed (int, bool, str or int array-like) – Input value to compare against expected. Dict may be of any depth but should contain Plain Old Data.

  • atol (int or 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.

  • forgive (list, optional) – Keys in top level which may change between expected and computed without triggering failure.


  • 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.


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