cf.Data.allclose¶
-
Data.allclose(y, rtol=None, atol=None)[source]¶ Whether an array is element-wise equal within a tolerance.
Return True if the data is broadcastable to array y and element-wise equal within a tolerance.
Two real numbers
xandyare considered equal if|x-y|<=atol+rtol|y|, whereatol(the tolerance on absolute differences) andrtol(the tolerance on relative differences) are positive, typically very small numbers. See the atol and rtol parameters.- Parameters
- Returns
Examples
>>> d = cf.Data([1000, 2500], 'metre') >>> e = cf.Data([1, 2.5], 'km') >>> bool(d.allclose(e)) True
>>> d = cf.Data(['ab', 'cdef']) >>> bool(d.allclose([[['ab', 'cdef']]])) True
>>> d = cf.Data([[1000, 2500], [1000, 2500]], 'metre') >>> e = cf.Data([1, 2.5], 'km') >>> bool(d.allclose(e)) True
>>> d = cf.Data([1, 1, 1], 's') >>> bool(d.allclose(1)) True