cf.Constructs.equals¶
-
Constructs.
equals
(other, rtol=None, atol=None, verbose=False, ignore_data_type=False, ignore_fill_value=False, ignore_compression=False, _ignore_type=False, _return_axis_map=False)[source]¶ Whether two
Constructs
instances are the same.Two real numbers
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.If data arrays are compressed then the compression type and 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 equality is only possible with another
Constructs
construct, or a subclass of one.NetCDF elements, such as netCDF variable and dimension names, do not constitute part of the CF data model and so are not checked on any construct.
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 “_FillValue” and “missing_value” properties are omitted from the comparison for the metadata constructs.
- 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 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 underlying arrays is ignored and only 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
Returns: bool
Whether the two instances are equal.
Examples:
>>> x.equals(x) True >>> x.equals(x.copy()) True >>> x.equals('something else') False