8000 DOC: Fix malformed docstrings in ma. by takanori-pskq · Pull Request #16296 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: Fix malformed docstrings in ma. #16296

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 6 commits into from
Jun 11, 2020
Merged

DOC: Fix malformed docstrings in ma. #16296

merged 6 commits into from
Jun 11, 2020

Conversation

takanori-pskq
Copy link

Fixing documents for some functions in numpy.ma(e.g. numpy.ma.vstack, https://numpy.org/devdocs/reference/generated/numpy.ma.vstack.html ). The documents is malformed because the indent of notes section is wrong.

Comment on lines 261 to 263
locdoc = "\n\n Notes\n -----\n "\
"The function is applied to both the _data"\
" and the _mask, if any."
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps instead we should use inspect.cleandoc(doc) before concatenating?

Copy link
Author

Choose a reason for hiding this comment

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

@eric-wieser Thanks for reviewing. I think that's right, so I fixed the code.

@charris charris changed the title DOC: fixing malformed documents DOC: Fix malformed docstrings in ma. May 19, 2020
Copy link
Contributor
@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

Applying cleandoc is definitely an improvement. Just had a quick thought on the linebreaking in locdoc.

takanori-pskq and others added 2 commits May 20, 2020 11:42
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
@takanori-pskq
Copy link
Author

I found a function ma.doc_note which solves the wrong indent problem, and the problem mentioned in the docstring of getdoc:

   .. warning::
     If the function docstring already contained a Notes section, the
     new docstring will have two Notes sections instead of appending a note
     to the existing section.

So I think it's better to use ma.doc_note.

@eric-wieser
Copy link
Member

Unfortunately ma.doc_note is also broken (#16309), but you're right that using it here is sensible.
Someone can fix doc_note in a later PR.

@eric-wieser
Copy link
Member

Proof that this seems to be working as intended: https://13466-908607-gh.circle-artifacts.com/0/doc/build/html/reference/generated/numpy.ma.vstack.html

@mattip
Copy link
Member
mattip commented May 20, 2020

Close/Reopen to clear CI failure

@takanori-pskq
Copy link
Author

Now doc_note was fixed (#16311), so this change also works correctly.

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
locdoc = "Notes\n-----\nThe function is applied to both the _data"\
" and the _mask, if any."
return '\n'.join((sig, doc, locdoc))
doc = ma.doc_note(doc, "The function is applied to both the _data "
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if as a follow-up we can set self.__wrapped__ = npfunc to avoid having to add a manual signature line.

@mattip mattip merged commit 02d66ec into numpy:master Jun 11, 2020
@mattip
Copy link
Member
mattip commented Jun 11, 2020

Thanks @takanori-pskq

@takanori-pskq takanori-pskq deleted the wb7 branch June 11, 2020 13:20
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.

5 participants
0