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

Skip to content

DOC: Add missing documentation for top-level functions #10106

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
31 of 32 tasks
eric-wieser opened this issue Nov 28, 2017 · 22 comments
Closed
31 of 32 tasks

DOC: Add missing documentation for top-level functions #10106

eric-wieser opened this issue Nov 28, 2017 · 22 comments

Comments

@eric-wieser
Copy link
Member

eric-wieser commented Nov 28, 2017

Exposed are:

Steps to document many of these:

  1. Find the long-form of the name, such as np.core.multiarray.uint16
  2. Add the documentation to numpy/add_newdocs.py in the appropriate place
  3. Find an appropriate place to link to the function within :/doc/source/reference/routines.*.rst - look at existing files to see how
Script to generate the above
from collections.abc import Callable
ndoc = set(
    v
    for k, v in vars(np).items()
    if isinstance(v, Callable) and v.__doc__ is None
)
ndoc = sorted(
    ndoc,
    key=lambda v: (isinstance(v, type) and issubclass(v, np .generic), v.__qualname__)
)
print('\n'.join(
   '* [ ] `{!r}` ({})'.format(
        v,
       ', '.join('`np.{}`'.format(k) for k, v2 in vars(np).items() if v2 is v)
    )
    for v in ndoc
))
@mohdsanadzakirizvi
Copy link

I would like to work on this as my first contribution, is it open? :)

@mattip
Copy link
Member

mattip commented May 23, 2018

It seems the basic classes are documented, no?

@eric-wieser
Copy link
Member Author

np.float16.__doc__ is None on my machine. Are you testing with PyPy? I think this might be another case of things happening after PyType_Ready.

YannickJadoul added a commit to YannickJadoul/numpy that referenced this issue Sep 1, 2018
YannickJadoul added a commit to YannickJadoul/numpy that referenced this issue Sep 14, 2018
charris pushed a commit that referenced this issue Sep 18, 2018
* DOC: add docstring for np.float16 (see #10106)

* DOC: add docstrings for uint8, uint16, uint32, uint64 (see #10106)

* DOC: make numeric types' docstrings char codes formatting consistent

* DOC: Adding documentation to C/Python compatible names of scalar types

* DOC: Adding platform-dependent aliases to scalar type docstrings

* DOC: Fix typos and minor issues in scalar type docstrings

* DOC: Add hard-coded aliases to scalar type docstrings

* DOC: Fix platform-dependent aliases in doc string of scalar types

* DOC: Fix indentation of numeric types' docstring

* TST: Add test checking for platform-dependent generation of numeric type docstrings

* TST: Fix docstring test failures when PYTHONOPTIMIZE/Py_OptimizeFlag > 1

* TST: Moving check of PYTHONOPTIMIZE for test_numerictypes.py::TestDocStrings into pytest.mark.skip decorator

* DOC: Cleanup code for adding docstrings to numeric types and mention canonical type name

* DOC: Cleaning up access of numeric type objects and character codes in dynamic docstring generation

* DOC: Prepend 'np.' to numeric type docstrings

* MAINT: Remove dead code, rename function

* DOC: Cleaning up numeric_type_aliases in core/_add_newdocs.py

* DOC: Fixing dynamic aliases in docstrings for complex scalar types

* DOC: Removing docstrings for complex scalar types in numpy/core/src/multiarray/scalartypes.c.src, as they are now set in numpy/core/_add_newdocs.py

* DOC: Merging lists of different dynamic aliases into one, and prepending 'np.' to fixed aliases

* DOC: Adding scalar type docstring improvements to release notes

* DOC: Tweak release notes
@eric-wieser
Copy link
Member Author

Thanks @YannickJadoul for knocking out a whole bunch of these!

@smellslikekeenspirit
Copy link

Hi, can I work on the documentation for the unticked functions? Or have they been done already?

@mattip
Copy link
Member

mattip commented Mar 24, 2019

@smellslikekeenspirit you can check by help(), if it returns None then the documentation is missing. If you find they are not missing, please let us know so we can mark them.

@engineerlisa
Copy link

engineerlisa commented Dec 10, 2019

Hello. Potential first time contributor here.

I re-ran the script up top and got:

  • <function <lambda> at 0x0044D300> (np.deprecate_with_doc) - DOC: Doc for deprecate_with_doc #17852
  • <class 'numpy.TooHardError'> (np.TooHardError) - DOC: adding docstring to TooHardError class #21471
  • <function __dir__ at 0x00B1BFA8> (np.__dir__)
  • <function __getattr__ at 0x009EE780> (np.__getattr__)
  • <built-in function int_asbuffer> (np.int_asbuffer)
  • <function loads at 0x04E096F0> (np.loads)
  • <function show at 0x04D23D20> (np.show_config)
  • <class 'numpy.bytes_'> (np.bytes0, np.bytes_, np.string_)
  • <class 'numpy.datetime64'> (np.datetime64)
  • <class 'numpy.str_'> (np.str0, np.unicode_, np.str_)
  • <class 'numpy.timedelta64'> (np.timedelta64)
  • <class 'numpy.void'> (np.void, np.void0)

I'm struggling to understand what needs to be accomplished. Any guidance would be appreciated.

Looking at np.datetime64 below. I see that np.datetime64.doc is None. But when checking help(), I see output for that. Can someone explain what the current help is returning, and what it is lacking?

>>> print(np.datetime64.__doc__)
None
>>> help(np.datetime64)
Help on class datetime64 in module numpy:

class datetime64(generic)
 |  Base class for numpy scalar types.
 |  
 |  Class from which most (all?) numpy scalar types are derived.  For
 |  consistency, exposes the same API as `ndarray`, despite many
 |  consequent attributes being either "get-only," or completely irrelevant.
 |  This is the class from which it is strongly suggested users should derive
 |  custom scalar types.
 |  
 |  Method resolution order:
 |      datetime64
[...]

@rgommers
Copy link
Member

Hi @engineerlisa, welcome! I would suggest to start with np.show_config, that's a straightforward function that is quite useful and not yet documented. What you want to do is:

  • write a docstring for the function in the same format as other NumPy function have their docstring. (note, look for generate_config_py in numpy/distutils/misc_util.py for show(), that's what generates the whole __config__.py file)
  • insert an entry for show_config in the reference guide. there's not really an obvious place for it, perhaps in https://numpy.org/devdocs/reference/routines.help.html is best. if you see a better place, please suggest that instead

@eric-wieser
Copy link
Member Author

Note that show_config already has a PR to document it at gh-9312, it would be worth building on the previous attempt.

@rgommers
Copy link
Member

Hmm, that PR looks a little complicated. @engineerlisa please have a look if that PR makes sense to you (@ghost is someone who disappeared from GitHub); the weird formatting stuff in the PR is because the docstring goes through some machinery that generates the __config__.py file so simply """ ... """ content won't work.

@eric-wieser I removed the "good first issue" label, the left overs aren't a matter of writing docs anymore. I think a maintainer should finish the last bits here.

@engineerlisa
Copy link

Thank you for getting back to me. I understand some parts of that PR. Based on your removing the tag, I'm going to find another candidate for my first contribution.

@eric-wieser
Copy link
Member Author

Just two left here

Both of these should be easy to document, so I'm going to add back the "good first issue" label

@kumudlakara
Copy link
Contributor

Hey, I'm a first time contributor and I would like to take up the remaining two functions if they are still open. Any guidance would be appreciated. Thanks!

@mattip
Copy link
Member

mattip commented Nov 23, 2020

Hi @kumudlakara. You should start with the contributor guide for an overview, especially the section on documentation and then the development workflow for the details. We don't assign issues, so be sure to mark your PR with xref gh-10106 to get a cross-reference to show up here, that way people will know you are working on it.

@kumudlakara
Copy link
Contributor

Alright, Thank you @mattip .

@Radhika14soni
Copy link

Hi, I'm a first time contributor and I would like to work on this issue if they are still open. Any guidance would be appreciated. Thanks!

@mattip
Copy link
Member

mattip commented Dec 17, 2020

Hi @Radhika14soni and welcome. I commented above on how to get familiar with the process. Since deprecate_with_doc is underway, the only remaining function lacking documentation is np.TooHardError. It is raised only by https://numpy.org/doc/stable/reference/generated/numpy.shares_memory.html, which should give you a hint as to the needed docstring.

@Radhika14soni
Copy link

@mattip Hello I'd like to work on it. Am I supposed to make changes in _add_newdocs.py?

@mattip
Copy link
Member

mattip commented Dec 17, 2020

Since this is a pure-python class, the change would be to add a docstring to the class definition like for the other exception classes in that file.

@mugunthanramesh
Copy link

mugunthanramesh commented Feb 24, 2021

Is there any works pending on this issue that I can take ? I am new to numpy contribution and looking for anything to work on

@melissawm
Copy link
Member

From the comments above it looks like this issue is taken care of, @mugunthanramesh . But feel free to browse other Documentation-related issues and ping me if you need help getting started. Cheers!

@mattip
Copy link
Member

mattip commented Feb 24, 2021

Closing then. Please open a new issue if there are still missing docstrings, this one is too difficult to navigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants