gemseo / utils

Hide inherited members

comparisons module

Data comparison tools.

gemseo.utils.comparisons.compare_dict_of_arrays(dict_of_arrays, other_dict_of_arrays, tolerance=0.0)[source]

Check if two dictionaries of NumPy arrays and/or SciPy sparse matrices are equal.

These dictionaries can be nested.

Parameters:
  • dict_of_arrays (Mapping[str, ArrayLike] | Mapping[str, Mapping[str, ArrayLike]]) – A dictionary of NumPy arrays and/or SciPy sparse matrices.

  • other_dict_of_arrays (Mapping[str, ArrayLike] | Mapping[str, Mapping[str, ArrayLike]]) – Another dictionary of NumPy arrays and/or SciPy sparse matrices.

  • tolerance (float) –

    A relative tolerance. The dictionaries are considered equal if for any key reference_name of reference_dict_of_arrays, norm(dict_of_arrays[name] - reference_dict_of_arrays[name]) /(1 + norm(reference_dict_of_arrays)) <= tolerance.

    By default it is set to 0.0.

Returns:

Whether the dictionaries are equal.

Return type:

bool