Python Forum
Matching two variables within a certain toleration
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matching two variables within a certain toleration
#3
https://docs.python.org/3/library/math.h...th.isclose Wrote:math.isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)¶
  • Return True if the values a and b are close to each other and False otherwise.

    Whether or not two values are considered close is determined according to given absolute and relative tolerances.

    rel_tol is the relative tolerance – it is the maximum allowed difference between a and b, relative to the larger absolute value of a or b. For example, to set a tolerance of 5%, pass rel_tol=0.05. The default tolerance is 1e-09, which assures that the two values are the same within about 9 decimal digits. rel_tol must be greater than zero.

    abs_tol is the minimum absolute tolerance – useful for comparisons near zero. abs_tol must be at least zero.

    If no errors occur, the result will be: abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol).

    The IEEE 754 special values of NaN, inf, and -inf will be handled according to IEEE rules. Specifically, NaN is not considered close to any other value, including NaN. inf and -inf are only considered close to themselves.

    New in version 3.5.
import math

if math.isclose(minf, m_fan_face):
    print('isclose')
Reply


Messages In This Thread
RE: Matching two variables within a certain toleration - by Yoriz - Apr-21-2019, 06:48 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020