cf.Index.equals

Index.equals(**kwargs)[source]

Whether two instances are the same.

Equality is strict by default. This means that:

  • 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 and y are considered equal if |x-y|<=atol+rtol|y|, where atol (the tolerance on absolute differences) and rtol (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, in general, equality is only possible with another object of the same type, 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: number, optional

The tolerance on absolute differences between real numbers. The default value is set by the cf.atol function.

rtol: number, optional

The tolerance on relative differences between real numbers. The default value is set by the cf.rtol function.

verbose: int or str or None, optional

If an integer from -1 to 3, or an equivalent string equal ignoring case to one of:

  • 'DISABLE' (0)

  • 'WARNING' (1)

  • 'INFO' (2)

  • 'DETAIL' (3)

  • 'DEBUG' (-1)

set for the duration of the method call only as the minimum cut-off for the verboseness level of displayed output (log) messages, regardless of the globally-configured cf.log_level. Note that increasing numerical value corresponds to increasing verbosity, with the exception of -1 as a special case of maximal and extreme verbosity.

Otherwise, if None (the default value), output messages will be shown according to the value of the cf.log_level setting.

Overall, the higher a non-negative integer or equivalent string that is set (up to a maximum of 3/'DETAIL') for increasing verbosity, the more description that is printed to convey information about the operation.

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_fill_value: bool, optional

If True then all _FillValue and missing_value properties are omitted from the comparison.

ignore_properties: (sequence of) str, optional

The names of properties to omit from the comparison.

ignore_compression: bool, optional

If False then the compression type and, if applicable, the underlying compressed arrays must be the same, as well as the arrays in their uncompressed forms. By default only the the arrays in their uncompressed forms are compared.

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 Index instance, or a subclass of one. If ignore_type is True then cf.Index(source=other) is tested, rather than the other defined by the other parameter.

Returns
bool

Whether the two instances are equal.

Examples

>>> f.equals(f)
True
>>> f.equals(f.copy())
True
>>> f.equals('a string')
False
>>> f.equals(f - 1)
False