Tolerance.compare
- Tolerance.compare(a, b, rtol, atol)[source]
Compare two values.
- Parameters:
- afloat
The first value.
- bfloat
The second value.
- rtolfloat
The relative tolerance.
- atolfloat
The absolute tolerance.
- Returns:
- bool
Trueif the values are close enough to be considered equal.Falseotherwise.
Notes
In this comparison,
bis considered the “true value”. This means that the relative part of the tolerance is computed as a fraction ofb.Examples
>>> tol = Tolerance() >>> tol.compare(1.0, 1.001, 0.001, 1e-06) True >>> tol.compare(1.0, 1.001, 0.0001, 1e-06) False