triqs.utility.h5diff.compare

triqs.utility.h5diff.compare(key, a, b, level, precision)[source]

Recursively compare two objects identified by key.

Dispatches on the runtime type of a (and asserts that b has the same type):

  • dict or HDFArchiveGroup – compare the set of keys and recurse on each value.

  • Gf / BlockGf / Block2Gf – defer to assert_gfs_are_close() / assert_block_gfs_are_close() / assert_block2_gfs_are_close().

  • Operator – check that (a - b).is_zero().

  • numpy.ndarray – defer to assert_arrays_are_close().

  • int, float, complex – check abs(a - b) < 1e-10.

  • bool / numpy.bool_ – check a == b.

  • list / tuple – compare length and recurse element-wise.

  • str – check a == b.

Any mismatch is appended to the module-level failures list rather than raised immediately, so that the full diff is reported at the end of h5diff().

Parameters:
keystr

Slash-separated path of the current node inside the archive, used in error messages.

a, bobject

Values to compare.

levelint

Current depth in the recursive walk, controls the indentation of the optional progress output emitted when the module-level verbose flag is set.

precisionfloat

Maximum allowed element-wise absolute difference passed to the underlying array / Green’s-function comparisons.

Raises:
NotImplementedError

If the type of a is not one of the supported categories listed above.