Tolerance.is_allclose
- Tolerance.is_allclose(A, B, rtol=None, atol=None)[source]
Check if two lists of values are element-wise close enough to be considered equal.
- Parameters:
- Alist of float
The first list of values.
- Blist of float
The second list of values.
- rtolfloat, optional
The relative tolerance. Default is
None
, in which caseself.relative
is used.- atolfloat, optional
The absolute tolerance. Default is
None
, in which caseself.absolute
is used.
- Returns:
- bool
True
if the values are close enough to be considered equal.False
otherwise.
Examples
>>> tol = Tolerance() >>> tol.is_allclose([1.0, 1.0], [1.0 + 1e-5, 1.0 + 1e-6]) False >>> tol.is_allclose([1.0, 1.0], [1.0 + 1e-6, 1.0 + 1e-6]) True >>> tol.is_allclose([0.0, 0.0], [0.0 + 1e-8, 0.0 + 1e-9]) False >>> tol.is_allclose([0.0, 0.0], [0.0 + 1e-9, 0.0 + 1e-9]) True