cf.Data.allclose

Data.allclose(y, rtol=None, atol=None)[source]

Returns True if two broadcastable arrays have equal values, False otherwise.

For numeric data arrays d.allclose(y, rtol, atol) is equivalent to (abs(d - y) <= atol + rtol*abs(y)).all(), otherwise it is equivalent to (d == y).all().

See also

all, any, isclose

Parameters:

y: data_like

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.

Returns:

out: bool

Examples:
>>> d = cf.Data([1000, 2500], 'metre')
>>> e = cf.Data([1, 2.5], 'km')
>>> d.allclose(e)
True
>>> d = cf.Data(['ab', 'cdef'])
>>> d.allclose([[['ab', 'cdef']]])
True
>>> d.allclose(e)
True
>>> d = cf.Data([[1000, 2500], [1000, 2500]], 'metre')
>>> e = cf.Data([1, 2.5], 'km')
>>> d.allclose(e)
True
>>> d = cf.Data([1, 1, 1], 's')
>>> d.allclose(1)
True