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

Skip to content

MAINT,BUG,DOC: Fix errors in _add_newdocs #13876

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 5 commits into from
Jul 6, 2019

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Jun 30, 2019

Intended to be backported to 1.16.x and 1.17.x - at the very least, the first two commits, but doing the whole patch-set is probably fine too.

Brought on by noticing some mistakes in gh-13847 that we'd ideally detect at build time.

…hon 3

Avoid using `_add_newdocs` if these functions do not exist.

Leaving the version-checking here so that we can backport to 1.16
This must have been lost in the multiarray / umath merge.

Found by noticing that `add_newdocs` was being called on an object that does not exist.
`ndarray._as_parameter_` is not a real thing
This caught us trying to document members that don't exist.
@@ -15,7 +16,7 @@
from numpy.core._multiarray_umath import *
from numpy.core._multiarray_umath import (
_fastCopyAndTranspose, _flagdict, _insert, _reconstruct, _vec_string,
_ARRAY_API, _monotonicity
_ARRAY_API, _monotonicity, _get_ndarray_c_version
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixes pymc-devs/pymc#3340, sympy/sympy#16556, and probably some others.

Copy link
Member

Choose a reason for hiding this comment

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

The name begins with a '_', shouldn't we be discouraging its use rather than adding more private methods to the public API?

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps, but removing it from the API broke downstream packages, and I don't think it was a deliberate choice.

Also, this member is even documented, so I think is intended to be "public but only for library use" or something.

@eric-wieser eric-wieser added this to the 1.17.0 release milestone Jun 30, 2019
@eric-wieser eric-wieser added the 09 - Backport-Candidate PRs tagged should be backported label Jun 30, 2019
@eric-wieser eric-wieser modified the milestones: 1.17.0 release, 1.18.0 release Jun 30, 2019
@charris
Copy link
Member

charris commented Jul 1, 2019

Hmm, I see that you dealt with potential back compatibility problems, so that's good. The new functions and add_newdoc should have official NumPy docstrings. I suppose that could be done later but it would probably be best to do it now when you have been looking at the functions.

@eric-wieser
Copy link
Member Author

I think adding full docstrings for the internal functions is probably not a good use of time or vertical space.

Note that add_newdocs does not appear in our web docs, and I'm inclined to say it shouldn't be public either. Either way, that means that it doesn't really matter if the docstring is in the standard format.

@charris
Copy link
Member

charris commented Jul 2, 2019

If a function has arguments, they need to be documented. And tell me about vertical space again :)

from numpy.core import numerictypes as _numerictypes
from numpy.core import dtype
from numpy.core.function_base import add_newdoc
from numpy.core.function_base import add_newdoc as _add_newdoc
Copy link
Member

Choose a reason for hiding this comment

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

Rather than changing the name on import, could you change function_base.add_newdoc to function_base._add_newdoc

Copy link
Member Author

@eric-wieser eric-wieser Jul 2, 2019

Choose a reason for hiding this comment

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

np.add_newdoc is public API, I think your suggestion will break that.

Copy link
Member

Choose a reason for hiding this comment

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

I see. What a mess: there is numpy.core.function_base and numpy.lib.function_base, each adds different things to __all__.

Since the implementation is specific to the _multiarray_umath module, why should add_newdoc be part of the public API? Its only use is at startup to modify the uninitialized tp_doc slot in _multiarray_umath methods.

Copy link
Member

Choose a reason for hiding this comment

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

... but not really relevant to this PR

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think np.add_newdoc should be public, but as a bugfix this PR tries not to break the status quo and leaves it where it is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Either way, evidently changing add_newdocs is a can of worms, so let's not mix it with the bug fixes in this patch.

@eric-wieser eric-wieser force-pushed the forbid-_add_newdocs-python branch from 8b8952c to b592e8f Compare July 3, 2019 06:36
@eric-wieser
Copy link
Member Author

I rolled back the last commit in this patch set, because I think most of the comments were directed at it, and it's also the least useful commit to backport

@eric-wieser eric-wieser changed the title MAINT/BUG/DOC: Fix errors in _add_newdocs and prevent them being reintroduced MAINT/BUG/DOC: Fix errors in _add_newdocs Jul 3, 2019
@eric-wieser
Copy link
Member Author

If a function has arguments, they need to be documented.

I'm going to claim immunity from this until the follow-up PR, since now this one doesn't add any new arguments or non-trivial functions :)

@mattip
Copy link
Member

mattip commented Jul 3, 2019

reopening to trigger shippable rebuild

@mattip mattip closed this Jul 3, 2019
@mattip mattip reopened this Jul 3, 2019
@tylerjereddy
Copy link
Contributor

Strange, I manually restarted the Shippable build to see if that helps

@mattip mattip merged commit 7ac7fa9 into numpy:master Jul 6, 2019
@mattip
Copy link
Member

mattip commented Jul 6, 2019

Shippable seems to be working now, thanks @eric-wieser

@eric-wieser
Copy link
Member Author

I'll spin off some backport PRs tonight, and resubmit the removed commit from this PR

@eric-wieser
Copy link
Member Author

eric-wieser commented Jul 8, 2019

@mattip, your squash merge ruined my attempt to share the commits across maintenance branches. I've created a commit to "undo" the squash merge at gh-13936

@charris charris changed the title MAINT/BUG/DOC: Fix errors in _add_newdocs MAINT,BUG,DOC: Fix errors in _add_newdocs Jul 8, 2019
eric-wieser added a commit that referenced this pull request Jul 9, 2019
mattip added a commit that referenced this pull request Jul 9, 2019
…-python

MAINT: Revert #13876, "MAINT,BUG,DOC: Fix errors in _add_newdocs"
@PerryGrossman
Copy link

Hi all,
Thanks for your work on this!
I am trying to resolve the numpy/theano issue that comes up when I use pymc3 (on Ubuntu 18.04 and a fresh Anaconda install). I tried updating numpy and theano; but I can only get to Theano 1.0.3 from conda. I pip installed Theano; but I can't figure out how to confirm that I have Theano 1.0.4.
I can't "conda install numpy 1.17" (package not found). "pip install numpy 1.17" indicates that the requirement is already satisfied.

I am trying work through this:
https://towardsdatascience.com/bayesian-modeling-airlines-customer-service-twitter-response-time-74af893f02c0
It fails at:
with pm.Model()
...

with a '_get_ndarray_c_version' error.

Suggestions?

@mattip
Copy link
Member

mattip commented Sep 1, 2019

@PerryGrossman why did you add that comment to this issue? Please open a new issue if you think numpy is at fault here, and follow the instructions vis-a-vis reporting python and numpy configuration. A stacktrace would also be helpful.

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