cfdm.Data.equals¶
-
Data.
equals
(other, rtol=None, atol=None, verbose=False, ignore_data_type=False, ignore_fill_value=False, ignore_compression=False, ignore_type=False, _check_values=True)[source]¶ Whether two data arrays are the same.
Equality is strict by default. This means that for data arrays to be considered equal:
- the units and calendar must be the same,
- the fill value must be the same (see the ignore_fill_value parameter), and
- the arrays must have same shape and data type, the same missing data mask, and be element-wise equal (see the ignore_data_type parameter).
Two numerical elements
x
andy
are considered equal if|x-y|<=atol+rtol|y|
, whereatol
(the tolerance on absolute differences) andrtol
(the tolerance on relative differences) are positive, typically very small numbers. See the atol and rtol parameters.The compression type and, if applicable, the underlying compressed arrays must be the same, as well as the arrays in their uncompressed forms. See the ignore_compression parameter.
Any type of object may be tested but, in general, equality is only possible with another cell measure construct, or a subclass of one. See the ignore_type parameter.
New in version 1.7.0.
Parameters: - other:
The object to compare for equality.
- atol: float, optional
The tolerance on absolute differences between real numbers. The default value is set by the
cfdm.ATOL
function.- rtol: float, optional
The tolerance on relative differences between real numbers. The default value is set by the
cfdm.RTOL
function.- ignore_fill_value:
bool
, optional If True then the fill value is omitted from the comparison.
- verbose:
bool
, optional If True then print information about differences that lead to inequality.
- ignore_data_type:
bool
, optional If True then ignore the data types in all numerical data array comparisons. By default different numerical data types imply inequality, regardless of whether the elements are within the tolerance for equality.
- ignore_compression:
bool
, optional If True then any compression applied to the underlying arrays is ignored and only the uncompressed arrays are tested for equality. By default the compression type and, if applicable, the underlying compressed arrays must be the same, as well as the arrays in their uncompressed forms
- ignore_type:
bool
, optional Any type of object may be tested but, in general, equality is only possible with another data array, or a subclass of one. If ignore_type is True then then
Data(source=other)
is tested, rather than theother
defined by the other parameter.
Returns: bool
Whether the two data arrays are equal.
Examples:
>>> d.equals(d) True >>> d.equals(d.copy()) True >>> d.equals('not a data array') False