-
-
Notifications
You must be signed in to change notification settings - Fork 11k
DOC: Examples in docstrings – tracking issue #21351
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
Comments
how can I help in this issue ? |
Take a look at the functions you use from NumPy, and see if the docstrings have examples similar to your non-trivial use cases. If not, comment below asking if it seems an example would help newer users figure out how to replicate what you do. |
This could be a good activity for a sprint with new contributors as most of them are NumPy users. I’ll add the “sprint” label to the issue. However, one doesn’t have to be a sprint participant to contribute to this initiative. |
Hi everyone! One thing that could also be tracked is whether the existing examples in docstrings are following the standards listed in the documentation. I've found an example in I'm willing to help on that. |
Hi, Just wanted to confirm. If the general DOCS (examples for various functions) are in the scope of this Issue or we are currently tracking only the DOC Strings. |
I was talking to @InessaPawson about that. I do believe that this issue could be, in fact, split into several different ones. Even the docstrings, this could be split in tracking down the ones that are there, the ones that are not, the ones that follow the standards, et cetera. |
We can use some examples in polynomial.py. What do you think about the following two (one for polymulx, the other for polyval2d): import numpy as np
from numpy.polynomial import polynomial as P
c=(-2, 0, 1)
P.polymulx(c)
#array([-0., -2., 0., 1.])
from numpy.polynomial.polynomial import polyval2d
a=polyval2d(2, -3j, [(-1j,1.5,2), (1,0.2j,0)]) #This is -1jx⁰y⁰ + 1.5x⁰y¹ + 2x⁰y² + 1x¹y⁰ + 0.2jx¹y¹ + 0x¹y², evaluated at x = 2 and y=-3j
#(-14.799999999999997-5.5j) |
@bhavukkalra This issue is only for examples in docstrings. Please file a separate issue for examples in other parts of the NumPy documentation. |
@dbrs01 this looks good - Would you like to submit a PR? |
Thank you Melisssa. I appreciate your feedback. I will do it (later) and
will continue including more examples. I have not been able to attend
meetings recently because I started a new job this past Monday and am in
the process of doing paperwork, installing my machine, going to the office
(no telework) and trying to get the most from my coworker from whom I
inherit tasks and whose last day of work is on May 30. I hope to be back
soon. See you!
…On Sat, May 14, 2022 at 7:13 AM Melissa Weber Mendonça < ***@***.***> wrote:
@dbrs01 <https://github.com/dbrs01> this looks good - Would you like to
submit a PR?
—
Reply to this email directly, view it on GitHub
<#21351 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABXBEHY2CZLX6V47USVDDZLVJ6RJJANCNFSM5TTIU3GA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Dilia B. Rueda S.
|
I can help with the PRs if you feel this is something that could help. Feel free to post the examples here and I can submit the PRs. |
Some time ago I wrote a script to find SciPy functions whose docstrings are missing the "Examples" section; there is a copy of that script in scipy/scipy#7168. (Edit: the script for SciPy, I just created a gist with a variation of that script that has been modified for NumPy: https://gist.github.com/WarrenWeckesser/c33d0236279cc5d73843f0497e14ed0e. (There is a lot that could be done with such a script; hack away on your own copy if you feel inspired.) Here's the output when I run that script with the development version (main branch) of NumPy. Note that some of these functions have very short docstrings that say something like "See $SOMEOTHERFUNC for details." This is probably intentional, and these are not good candidates for new contributors or for use in a sprint. Also, it looks like some of these might be "namespace pollution": names from the main numpy namespace that also ended up in a submodule. When in doubt, ask the NumPy devs to confirm that a function should get an "Examples" section before you spend time working on it.
|
FWIW this check is also now built-in to the numpydoc docstring validator, which can be run during a doc build. For example, when building the docs locally you can add |
@WarrenWeckesser Thank you so much for sharing this information! I’ll file a separate issue for each function after consulting with our core developers. |
We should rerun the script |
The old script was missing some functions, which I think is because of the issues related to _ArrayFunctionDispatcher from last year. For example #23032 and #23307. I added the following lines to the script. EDIT: Found better way, using
Then I replaced
Here is the new list:
Prior to the change, there were only 24. I noticed the script was missing
I tried adding |
When you add
If you want to filter the log so that only the warnings associated with the validation checks are stored, try:
|
I'll share the output as a file buildlog.log, rather than copy/paste the output here. There are 1808 items. |
I modified the script above to use While working on this, I noticed that there were several functions on this list that had docstrings that were not published on the web version of the docs. This script uses the |
This commit updates the routines.ma.rst file to enable web docs for several routines in the `ma` module. Similar to numpy#23352 See numpy#21351 for a script to locate similar items in any module. [skip actions] [skip azp] [skip cirrus]
This commit updates routines.strings.rst to enable webdocs for for several routings in the `strings` module. See numpy#21351 for a script to automatically locate similar issues. [skip actions] [skip azp] [skip cirrus]
Created gist of the script to run directly into a python shell. |
Missing Docstringsnp (12)
np.char (7)
np.ctypeslib (4)
np.lib (2)
np.linalg (10)
np.ma (6)
np.rec (1)
|
I sent too many PRs already. I'll wait for review to add more. |
@luxedo If you put |
Thank you! My bad. |
Correct. They have to be in the commit message as well. Putting them in the comments of the PR is not sufficient (learned that myself a few weeks ago). Any time you add more changes in another commit, you have to add these tags to the commit message to make sure the correct CI jobs are run. |
Also please try to combine small example additions together into one PR |
I did like to add examples for the numpy.char.array, currently working on it. |
Adding example code snippets to np.char.isspace function, currently in the process of adding it |
adding example code snippets to np.ma.convolve function currently in the process of adding it |
Uh oh!
There was an error while loading. Please reload this page.
"Examples, more examples, and more detailed examples" is the recurrent theme in the feedback about the NumPy documentation we received via the 2020 and 2021 NumPy user surveys.
If you come across a docstring where a function is missing an example or more/better examples are needed, please add a comment below.
Re: the “sprintable” label This could be a good activity for a sprint with new contributors as most of them are NumPy users. However, one doesn’t have to be a sprint participant to contribute to this initiative.
The text was updated successfully, but these errors were encountered: