Skip to content

DOC: add missing routines to reference guide #13214

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

Closed
wants to merge 7 commits into from

Conversation

normallytangent
Copy link

@normallytangent normallytangent commented Mar 29, 2019

These have their relevant docstrings. I'll add them to the reference guide.

  • 'compare_chararrays': 'numpy.core._multiarray_umath.compare_chararrays',
  • 'add_newdoc': 'numpy.core.function_base.add_newdoc',
  • 'byte_bounds': 'numpy.lib.utils.byte_bounds',
  • 'deprecate': 'numpy.lib.utils.deprecate',
  • 'get_include': 'numpy.lib.utils.get_include',
  • 'who': 'numpy.lib.utils.who',

To Deprecate:

  • 'disp': 'numpy.lib.function_base.disp',
  • 'recfromcsv': 'numpy.lib.npyio.recfromcsv',
  • 'recfromtxt': 'numpy.lib.npyio.recfromtxt',
  • 'safe_eval': 'numpy.lib.utils.safe_eval'
  • 'Tester': 'numpy.testing._private.nosetester.NoseTester',

@normallytangent
Copy link
Author

When I make html only the part that I enlist in the rst documentation file appears in the resulting HTML. I am still learning about autosummary so this might take some time from my end.

@mattip
Copy link
Member

mattip commented Mar 30, 2019

When I make html only the part that I enlist in the rst documentation file appears in the resulting HTML

The docstrings come from numpy, so you need to install the latest version of numpy into the python3.6 that is used to build documentation. The directions say "Note that you can eg. install NumPy to a temporary location and set the PYTHONPATH environment variable appropriately.". Another way is to run python3.6 in a virtual environment, then you can call pip install . in the numpy (not numpy/doc) directory. It is not recommended to do pip3 install for a numpy development version outside a virtual environment since then any other python3 task you do will pick up this development numpy.

@mattip
Copy link
Member

mattip commented Mar 30, 2019

You can also run python3.6 runtests.py --shell which will drop you into a shell which should pick up the correct numpy version.

@mattip
Copy link
Member

mattip commented Mar 30, 2019

xref #12385

@mattip
Copy link
Member

mattip commented Mar 30, 2019

If you add items to your checklist, please be sure they do not appear in #13222

@normallytangent
Copy link
Author

When I make html only the part that I enlist in the rst documentation file appears in the resulting HTML

The docstrings come from numpy, so you need to install the latest version of numpy into the python3.6 that is used to build documentation. The directions say "Note that you can eg. install NumPy to a temporary location and set the PYTHONPATH environment variable appropriately.". Another way is to run python3.6 in a virtual environment, then you can call pip install . in the numpy (not numpy/doc) directory. It is not recommended to do pip3 install for a numpy development version outside a virtual environment since then any other python3 task you do will pick up this development numpy.

Thank you! This helped me set up the virtualenv and install numpy in that. I ran make html right after in numpy/doc dir. But still no luck with the autosummary

@mattip
Copy link
Member

mattip commented Mar 31, 2019

Can you clarify what you mean by "no luck with the autosummary"? Do you mean that changes you make to docstrings do not show up in the html you view after a build? Are you cleaning out the relevant files so they are regenerated (one way to do that is make clean)?

@normallytangent
Copy link
Author

normallytangent commented Mar 31, 2019

Can you clarify what you mean by "no luck with the autosummary"? Do you mean that changes you make to docstrings do not show up in the html you view after a build? Are you cleaning out the relevant files so they are regenerated (one way to do that is make clean)?

I'm sorry, I wasn't clear.
I'm running Python 3.6.5 and Sphinx 2.0.0. I did run make clean prior to running make html.
I navigated to the html corresponding to this rst doc, clicked on the link formed for compare_chararrays.
I expected that the html page would be populated with the summary blurb extracted from its docstring here. But it is not: see screenshot.
I'm afraid it's my lack of understanding of how the documentation is generated. So I'll depend on the CI while I learn to use Sphinx. My apologies for having taken this thread completely off-track from the PR
image

@mattip
Copy link
Member

mattip commented Mar 31, 2019

Looking at the documentation as built in CI everything looks fine. There is a line now under Comparison for compare_chararray which is a link to the docstring.

Copy link
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now.

I do wonder if we should deprecate that function (in a separate issue). It looks to be a weird dispatcher between np.equal and np.char.equal (and the other 5 operators)

@normallytangent normallytangent changed the title DOC: add missing character routine DOC: add missing routines to reference guide Apr 1, 2019
@normallytangent
Copy link
Author

#12385 mentions the need to set the __module__ attribute for the added routines.
#13054 also edited the list of undocumented routines in numpy/tests/test_public_api.py
I need to do the same for the items that I have added, right?

@mattip
Copy link
Member

mattip commented Apr 2, 2019

Yes, you need to change the __module__ attribute of those you choose to "make official" by documenting. Since you have documented compare_chararrays as part of the char module, it should be removed from the top level numpy namespace, and added to char, but will require a deprecation period. The easiest way to do that would be to create a second function in the numpy namespace that warns, then calls the numpy.char-exposed one.

Once you change the __module__ attribute, the test should fail. You will need to adjust the test to make it pass.

We have a special syntax for adding a DeprecationWarning, grep around the python files for examples. There should be a comment above the warning with the date, version, and github issue.

@mattip
Copy link
Member

mattip commented Apr 2, 2019

I think I would prefer to put disp on the list for deprecation. While harmless, it seems not very useful.

@seberg
Copy link
Member

seberg commented Apr 2, 2019

Would be +1 for disp deprecation. Since from numpy import * is not common anymore, I guess it is by now unused anyway, and it was always probably just there for those switching from matlab.

@eric-wieser
Copy link
Member

+1 on deprecating disp, it makes no sense in numpy and is just a weird wrapper for print

@normallytangent
Copy link
Author

  • Can someone tell me if I'm deprecating it right? I couldn't decide between ..deprecated:: 1.17.0 and ..warning:: <some message> When should I choose one over the other?
  • Are the above items in the checklist to be deprecated with immediate effect? Or should they carry a warning that they would be deprecated in future releases?
  • Also, how can I make a deprecation warning more informative. What alternative to disp should I provide?

@mattip
Copy link
Member

mattip commented Apr 4, 2019

All deprecations that were part of the public API need a few versions before actual removal.


get_include

Deprecation warning
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of this title, but I guess better than not having any reference at all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had initially thought of Warning Generator for the title here, but that seemed ambiguous. It may not be intuitive for a beginner looking for deprecate. What are we looking for in a good title?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is Handling Old Functions in NumPy for the title?

@normallytangent
Copy link
Author

The azure-pipeline errors are because I did not change the test_io.py.
I proceeded to deprecate 'recfromtxt' and 'recfromcsv' because xref #12385 prefers deprecation.
I think that those might be useful since they're adding functionality on top of genfromtxt. I found answers on Stack Overflow that suggest using recfromcsv for csv files. So there are at least some people who use it.
Should they be deprecated?

If not, I will instead improve their documentation.
The doc/source/user/basics.io.genfromtxt.rst (doc) for these is incomplete. It mentions only one and two arguments (dtype and delimiter) to be set, respectively, while in the source code there are two additional args to be set by the user (source).
#3830 also mentioned the need to document the two in doc/source/reference/routines.io.rst (here)

@mattip
Copy link
Member

mattip commented Jul 9, 2019

Closing, replaced by #13847

@mattip mattip closed this Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants