cf.equals

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

True if and only if two objects are logically equal.

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

Parameters :
x, y :

The objects to compare for equality.

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 equal.

Examples

>>> f
<CF Field: rainfall_rate(latitude(10), longitude(20)) kg m2 s-1>
>>> cf.equals(f, f)
True
>>> cf.equals(1.0, 1.0)
True
>>> cf.equals(1.0, 33)
False
>>> cf.equals('a', 'a')
True
>>> cf.equals('a', 'b')
False
>>> type(x), x.dtype
(<type 'numpy.ndarray'>, dtype('int64'))
>>> y = x.copy()
>>> cf.equals(x, y)
True
>>> cf.equals(x, x+1)
False
>>> class A(object):
...     pass
...
>>> a = A()
>>> b = A()
>>> cf.equals(a, a)
True
>>> cf.equals(a, b)
False

Previous topic

cf.unsqueeze

Next topic

cf.equivalent

This Page