compare

qcelemental.compare(expected, computed, label=None, *, equal_phase=False, quiet=False, return_message=False, return_handler=None)[source]

Returns True if two integers, strings, booleans, or integer arrays are element-wise equal.

Parameters
  • expected (Union[int, bool, str, List[int], ndarray]) – int, bool, str or array-like of same. Reference value against which computed is compared.

  • computed (Union[int, bool, str, List[int], ndarray]) – int, bool, str or array-like of same. Input value to compare against expected.

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

  • equal_phase (bool) – 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 (Optional[Callable]) – Function to control printing, logging, raising, and returning. Specialized interception for interfacing testing systems.

Return type

Union[bool, Tuple[bool, str]]

Returns

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

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

Notes

  • Akin to np.array_equal.

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