Tolerance.is_close
- Tolerance.is_close(a, b, rtol=None, atol=None)[source]
Check if two values are close enough to be considered equal.
- Parameters:
- afloat
The first value.
- bfloat
The second value.
- 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_close(1.0, 1.000001) True >>> tol.is_close(1.0, 1.00001) True >>> tol.is_close(1.0, 1.0001) True >>> tol.is_close(1.0, 1.001) True >>> tol.is_close(1.0, 1.01) False