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

Skip to content

MAINT/DEP: properly implement ndarray.__pos__ #11450

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 3 commits into from
Jul 26, 2018

Conversation

mhvk
Copy link
Contributor

@mhvk mhvk commented Jun 29, 2018

fixed #9081

For regular arrays, we now give a deprecation warning if np.positive cannot handle it; for ndarray subclasses that override array_ufunc, we pass on the type error.

PyObject *mod;
if (mod) {
Py_DECREF(mod);
}
Copy link
Member

Choose a reason for hiding this comment

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

This looks wrong. What is mod?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, leftover from debugging!! (I had the problem that has_not_default... doesn't work when an error is set)

@mattip
Copy link
Member

mattip commented Jun 29, 2018

Why was this different, historically, than array_negative or array_absolute? It seems strange to special case only array_positive

@mhvk mhvk force-pushed the ndarray-implement-pos branch 2 times, most recently from 325e0b6 to 31ac6cd Compare June 29, 2018 14:05
@mhvk
Copy link
Contributor Author

mhvk commented Jun 29, 2018

@mattip - I'm guessing it was just a short-cut. Certainly, np.positive didn't exist until recently.

@@ -61,7 +61,7 @@ get_non_default_array_ufunc(PyObject *obj)
* Returns 1 if this is the case, 0 if not.
*/

static int
NPY_NO_EXPORT int
Copy link
Member

Choose a reason for hiding this comment

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

nit: This doesn't belong in this PR

Copy link
Member

Choose a reason for hiding this comment

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

edit: nevermind

@eric-wieser
Copy link
Member

Commit tag should definitely contain DEP, since this has a deprecation

@eric-wieser eric-wieser changed the title MAINT: properly implement ndarray.__pos__ MAINT/DEP: properly implement ndarray.__pos__ Jun 30, 2018
@mhvk mhvk force-pushed the ndarray-implement-pos branch from b770252 to f13ab50 Compare June 30, 2018 22:10
@mhvk
Copy link
Contributor Author

mhvk commented Jun 30, 2018

OK, I changed the commit message to include "DEP".

}
/* 2018-06-28, 1.16.0 */
if (DEPRECATE("Applying '+' to a non-numerical array is "
"ambigous. Returning a copy, but in the future "
Copy link
Member

@eric-wieser eric-wieser Jun 30, 2018

Choose a reason for hiding this comment

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

Typo: ambiguous.

Is this even true? It's just ill-defined (no possible meanings), not ambiguous (>1 possible meanings).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, replaced with "ill-defined".

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.

Just drawing attention to my comment above

@mhvk mhvk force-pushed the ndarray-implement-pos branch from f13ab50 to ac1e129 Compare July 1, 2018 14:03
@mhvk
Copy link
Contributor Author

mhvk commented Jul 2, 2018

@eric-wieser - I addressed your comment. OK to merge?

@mattip
Copy link
Member

mattip commented Jul 26, 2018

@eric-wieser could you comment on the changes you requested?

@mhvk it seems a rebase is needed

mhvk added 3 commits July 26, 2018 09:54
Rather than rely on +array doing that for it.
For regular arrays, we now give a deprecation warning if
np.positive cannot handle it; for ndarray subclasses that override
__array_ufunc__, we pass on the type error.
@mhvk mhvk force-pushed the ndarray-implement-pos branch from ac1e129 to 3207785 Compare July 26, 2018 14:04
@mhvk
Copy link
Contributor Author

mhvk commented Jul 26, 2018

@mattip - thanks for noticing... now rebased and approved, so can go in if tests pass.

@mhvk mhvk merged commit ff8197b into numpy:master Jul 26, 2018
@mhvk mhvk deleted the ndarray-implement-pos branch July 26, 2018 15:08
@charris charris changed the title MAINT/DEP: properly implement ndarray.__pos__ MAINT/DEP: properly implement ndarray.__pos__ Nov 10, 2018
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.

ENH: call np.positive in ndarray.__pos__, and issue a deprecation warning when it falls
3 participants