cf.equivalent

cf.equivalent(x, y, rtol=None, atol=None, traceback=False)[source]

True if and only if two objects are logically equivalent.

If the first argument, x, has an equivalent method then it is used, and in this case equivalent(x, y) is the same as x.equivalent(y).

Parameters:
x, y :

The objects to compare for equivalence.

atol
: float, optional

The absolute tolerance for all numerical comparisons, By default the value returned by the ATOL function is used.

rtol
: float, optional

The relative tolerance for all numerical comparisons, By default the value returned by the RTOL function is used.

traceback
: bool, optional

If True then print a traceback highlighting where the two objects differ.

Returns:
out
: bool

Whether or not the two objects are equivalent.

Examples:
>>> f
<CF Field: rainfall_rate(latitude(10), longitude(20)) kg m2 s-1>
>>> cf.equivalent(f, f)
True
>>> cf.equivalent(1.0, 1.0)
True
>>> cf.equivalent(1.0, 33)
False
>>> cf.equivalent('a', 'a')
True
>>> cf.equivalent('a', 'b')
False
>>> cf.equivalent(cf.Data(1000, units='m'), cf.Data(1, units='km'))
True

For a field, f:

>>> cf.equivalent(f, f.transpose())
True