-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
doc: clarify the behavior of approx
#13341
doc: clarify the behavior of approx
#13341
Conversation
This seems like a very special case, so IMHO this should be mentioned somewhere further down with the other notes, but certainly not in the first two sentences before even explaining what the function is there for. |
Thanks @The-Compiler for your comment. I moved the note further down as you suggested and added an example. Could you please take a look at my update? |
src/_pytest/python_api.py
Outdated
@@ -632,6 +632,12 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase: | |||
>>> ["foo", 1.0000005] == approx([None,1]) | |||
False | |||
|
|||
Note that unlike built-in equality, this function considers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the note and the example, but how about moving this to a proper .. note::
section, similar to the one we have at the bottom?
pytest/src/_pytest/python_api.py
Lines 684 to 693 in 9a7dbd8
.. note:: | |
``approx`` can handle numpy arrays, but we recommend the | |
specialised test helpers in :std:doc:`numpy:reference/routines.testing` | |
if you need support for comparisons, NaNs, or ULP-based tolerances. | |
To match strings using regex, you can use | |
`Matches <https://github.com/asottile/re-assert#re_assertmatchespattern-str-args-kwargs>`_ | |
from the | |
`re_assert package <https://github.com/asottile/re-assert>`_. |
I would add your section under a .. note::
after that one about numpy arrays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nicoddemus for reviewing this PR!
I just pushed a commit to address your comment. CI is green.
for more information, see https://pre-commit.ci
Backport to 8.3.x: 💚 backport PR created✅ Backport PR branch: Backported as #13352 🤖 @patchback |
Thanks @natmokval! |
Fixes #13218 (cherry picked from commit 6964cf1) Co-authored-by: Natalia Mokeeva <[email protected]>
A small documentation fix to clarify the behavior of
approx
.closes #13218