-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
MAINT: FutureWarning for changes to np.average subclass handling #7433
Conversation
@@ -989,7 +989,17 @@ def average(a, axis=None, weights=None, returned=False): | |||
TypeError: Axis must be specified when shapes of a and weights differ. | |||
|
|||
""" | |||
a = np.asanyarray(a) | |||
# replace the next few lines with "a = np.asanyarray(a)" in the future |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If doing this, should add comment with data and release to help track when to change. Something like
# 3/19/2016 1.12.0
Also add something to the release notes. The 1.11.0 notes have a |
"will do so in the future to match the behaior of most " | ||
"other numpy functions such as np.mean. In particular, " | ||
"this means calls which returned a scalar may return a " | ||
"0-d subclass object instead.", FutureWarning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I hope to change this everywhere else as well by 1.12 (and probably force it in the numpy code base for the most part), could you add a stacklevel=2?
0105073
to
6b0301e
Compare
Updated |
☔ The latest upstream changes (presumably #7437) made this pull request unmergeable. Please resolve the merge conflicts. |
I am not sure what is the status of this now that #7406 has been merged. It if is still needed it needs a rebase on master and there is a behaior -> behavior typo to fix (missing v). EDIT: in two places. |
@ahaldane What is the status of this? Note also the previous comment. Looks straight forward to me. |
Yeah, looks like we should do this. I'll fix it up tonight probably. |
6b0301e
to
5917372
Compare
Thanks Allan. |
Just a reminder that for 1.12.0 the behaviour was supposed to be changed to allow subclasses in |
This slightly rolls back the changes to np.average in #7382, so that we emit a
FutureWarning
ifnp.average
is called on anndarray
subclass. In the future,np.average
will preserve subclasses, just likenp.mean
and almost all other numpy methods.This is to fix #7403. Note that the specific case in #7403 will probably also be fixed by #7406, but this PR should make sure we aren't more generally breaking anyone's code (for now).