gemseo.utils.comparisons module#
Data comparison tools.
- 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, ndarray[Any, dtype[floating[Any]]] | coo_matrix | spmatrix | sparray] | Mapping[str, Mapping[str, ndarray[Any, dtype[floating[Any]]] | coo_matrix | spmatrix | sparray]]) -- A dictionary of NumPy arrays and/or SciPy sparse matrices.
other_dict_of_arrays (Mapping[str, ndarray[Any, dtype[floating[Any]]] | coo_matrix | spmatrix | sparray] | Mapping[str, Mapping[str, ndarray[Any, dtype[floating[Any]]] | coo_matrix | spmatrix | sparray]]) -- 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
ofreference_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: