cf.FieldList.equals¶
-
FieldList.
equals
(other, rtol=None, atol=None, verbose=False, ignore_data_type=False, ignore_fill_value=False, ignore_properties=(), ignore_compression=False, ignore_type=False, ignore=(), traceback=False, unordered=False)[source]¶ Whether two field lists are the same.
Equality requires the two field lists to have the same length and for the the field construct elements to be equal pair-wise, using their
equals
methods.Any type of object may be tested but, in general, equality is only possible with another field list, or a subclass of one. See the ignore_type parameter.
Equality is between teo field constructs is strict by default. This means that for two field constructs to be considered equal they must have corresponding metadata constructs and for each pair of constructs:
- the same descriptive properties must be present, with the same values and data types, and vector-valued properties must also have same the size and be element-wise equal (see the ignore_properties and ignore_data_type parameters), and
- if there are data arrays then they must have same shape and data type, the same missing data mask, and be element-wise equal (see the ignore_data_type parameter).
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.
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.
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 field construct and metadata constructs.- verbose:
bool
, optional If
True
then print information about differences that lead to inequality.- ignore_properties: sequence of
str
, optional The names of properties of the field construct (not the metadata constructs) to omit from the comparison. Note that the “Conventions” property is always omitted by default.
- 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- ignore_type:
bool
, optional Any type of object may be tested but, in general, equality is only possible with another field list, or a subclass of one. If ignore_type is True then
FieldList(source=other)
is tested, rather than theother
defined by the other parameter.- unordered:
bool
, optional TODO
Returns: bool
Whether the two field lists are equal.
Examples:
>>> fl.equals(fl) True >>> fl.equals(fl.copy()) True >>> fl.equals(fl[:]) True >>> fl.equals('not a FieldList instance') False