cf.equals

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

True if two objects are logically equal, False otherwise.

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

>>> x
<CF Field: rain(10,20)>
>>> cf.equals(x,x)
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.eq

Next topic

cf.ge

This Page