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, ndarray | spmatrix] | Mapping[str, Mapping[str, ndarray | spmatrix]]) – A dictionary of NumPy arrays and/or SciPy sparse matrices.
other_dict_of_arrays (Mapping[str, ndarray | spmatrix] | Mapping[str, Mapping[str, ndarray | spmatrix]]) – 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: