cf.FieldAncillary.allclose¶
-
FieldAncillary.
allclose
(y, atol=None, rtol=None)[source]¶ Returns True if two broadcastable field ancillarys have equal array values to within numerical tolerance.
For numeric data arrays
f.allclose(y, atol, rtol)
is equivalent to(abs(f - y) <= atol + rtol*abs(y)).all()
; for other data types it is equivalent to(f == y).all()
.See also
Examples 1: >>> x = f.allclose(g)
Parameters: - y: data-like object
The object to be compared with the data array. y must be broadcastable to the data array and if y has units then they must be compatible.
A data-like object is any object containing array-like or scalar data which could be used to create a
cf.Data
object.- Example:
Instances,
x
, of following types are all examples of data-like objects (becausecf.Data(x)
creates a validcf.Data
object):int
,float
,str
,tuple
,list
,numpy.ndarray
,cf.Data
,cf.Coordinate
,cf.Field
.
- atol:
float
, optional The absolute tolerance for all numerical comparisons, By default the value returned by the
cf.ATOL
function is used.- rtol:
float
, optional The relative tolerance for all numerical comparisons, By default the value returned by the
cf.RTOL
function is used.
Returns: - out:
bool
Whether or not the two data arrays are equivalent.
Examples 2: