cf.equals¶
-
cf.
equals
(x, y, rtol=None, atol=None, ignore_fill_value=False, 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 caseequals(x, y)
is equivalent tox.equals(y)
. Else if the second argument, y, has anequals
method then it is used, and in this caseequals(x, y)
is equivalent toy.equals(x)
.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.- ignore_fill_value : bool, optional
If True then
cf.Data
arrays with different fill values are considered equal. By default they are considered unequal.- 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