Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[3.12] gh-126165: Improve docs of function math.isclose (GH-126215) #126381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions Doc/library/cmath.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,21 @@ Classification functions
``False`` otherwise.

Whether or not two values are considered close is determined according to
given absolute and relative tolerances.
given absolute and relative tolerances. If no errors occur, the result will
be: ``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``.

*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)``.
within about 9 decimal digits. *rel_tol* must be nonnegative and less
than ``1.0``.

*abs_tol* is the absolute tolerance; it defaults to ``0.0`` and it must be
nonnegative. When comparing ``x`` to ``0.0``, ``isclose(x, 0)`` is computed
as ``abs(x) <= rel_tol * abs(x)``, which is ``False`` for any ``x`` and
rel_tol less than ``1.0``. So add an appropriate positive abs_tol argument
to the call.

The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be
handled according to IEEE rules. Specifically, ``NaN`` is not considered
Expand Down
18 changes: 10 additions & 8 deletions Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,21 @@ Number-theoretic and representation functions
``False`` otherwise.

Whether or not two values are considered close is determined according to
given absolute and relative tolerances.
given absolute and relative tolerances. If no errors occur, the result will
be: ``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``.

*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)``.
within about 9 decimal digits. *rel_tol* must be nonnegative and less
than ``1.0``.

*abs_tol* is the absolute tolerance; it defaults to ``0.0`` and it must be
nonnegative. When comparing ``x`` to ``0.0``, ``isclose(x, 0)`` is computed
as ``abs(x) <= rel_tol * abs(x)``, which is ``False`` for any ``x`` and
rel_tol less than ``1.0``. So add an appropriate positive abs_tol argument
to the call.

The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be
handled according to IEEE rules. Specifically, ``NaN`` is not considered
Expand Down
Loading