cf.CoordinateReference.equals¶
-
CoordinateReference.
equals
(other, rtol=None, atol=None, verbose=False, ignore_type=False)[source]¶ Whether two coordinate reference constructs are the same.
Equality is strict by default. This means that:
the datum and coordinate conversion components must have the same string and numerical parameters.
The dimension coordinate, auxiliary coordinate and domain ancillary constructs of the coordinate reference constructs are not considered, because they may only be correctly interpreted by the field constructs that contain the coordinate reference constructs in question. They are, however, taken into account when two fields constructs are tested for equality.
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. The data type of the numbers is not taken into consideration. See the atol and rtol parameters.Any type of object may be tested but, in general, equality is only possible with another coordinate reference construct, or a subclass of one. See the ignore_type parameter.
NetCDF elements, such as netCDF variable and dimension names, do not constitute part of the CF data model and so are not checked.
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.- verbose:
bool
, optional If True then print information about differences that lead to inequality.
- ignore_type:
bool
, optional Any type of object may be tested but, in general, equality is only possible with another coordinate reference construct, or a subclass of one. If ignore_type is True then
CoordinateReference(source=other)
is tested, rather than theother
defined by the other parameter.
- Returns
bool
Whether the two coordinate reference constructs are equal.
Examples:
>>> c.equals(c) True >>> c.equals(c.copy()) True >>> c.equals('not a coordinate reference') False