Skip to content

BUG: ensure axis=None gets passed on correctly to ufunc.reduce.#9104

Closed
mhvk wants to merge 1 commit intonumpy:masterfrom
mhvk:array_ufunc_reduce_argument_bug_fix
Closed

BUG: ensure axis=None gets passed on correctly to ufunc.reduce.#9104
mhvk wants to merge 1 commit intonumpy:masterfrom
mhvk:array_ufunc_reduce_argument_bug_fix

Conversation

@mhvk
Copy link
Contributor

@mhvk mhvk commented May 11, 2017

By mistake, any arguments to ufunc.reduce, ufunc.accumulate, and ufunc.reduceat that were None were removed, rather than just removing the 'out' argument. This is corrected here, with tests added.

fixes #9102

By mistake, any arguments to ufunc.reduce, ufunc.accumulate,
and ufunc.reduceat that were None were removed, rather than just
removing the 'out' argument.  This is corrected here, with
tests added.
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.

Needs a test with out != None, because that will fail!

if (i == 3) {
Py_DECREF(obj);
if (i == 3) {
/* remove out=None */
Copy link
Member

Choose a reason for hiding this comment

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

Does this remove kwarg['out'] == None too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that is removed in PyUFunc_CheckOverride before we even get here.

}
obj = PyTuple_GetSlice(args, 3, 4);
}
PyDict_SetItemString(*normal_kwds, kwlist[i], obj);
Copy link
Member

Choose a reason for hiding this comment

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

This isn't going to fly - out must be a single value for reduce, not a tuple

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Darn, you're absolutely right. As is, things simply break with out given. I think fixing it here is better.

Copy link
Member

Choose a reason for hiding this comment

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

At which point, I'd argue that for reduce and accumulate, never passing out=None is just unhelpful - can we do the opposite, and always set it?

@eric-wieser
Copy link
Member

Although perhaps fixing out should go in a separate PR?

@eric-wieser
Copy link
Member

Can you rebase on 14ff219 to make the backport easy?

@mhvk
Copy link
Contributor Author

mhvk commented May 12, 2017

@eric-wieser - see #9105 - I think it has now become clear we should discuss what to do with out separately.

@eric-wieser
Copy link
Member

Is this PR superseded by #9106?

@mhvk
Copy link
Contributor Author

mhvk commented May 12, 2017

Yes, if you think #9106 is OK, then this can be dropped.

@eric-wieser
Copy link
Member

I think #9106 will soon be ok, anyway. Can you rebase it on 14ff219 for ease of backporting? (and merging future backports)

@charris charris modified the milestones: 1.13.0 release, 1.14.0 release May 12, 2017
@charris
Copy link
Member

charris commented May 15, 2017

Closing in favor of #9106.

@charris charris closed this May 15, 2017
@charris charris removed this from the 1.13.0 release milestone May 18, 2017
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label May 28, 2017
@mhvk mhvk deleted the array_ufunc_reduce_argument_bug_fix branch August 31, 2017 23:49
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.

np.max() doesn't behave properly for ndarray subclasses that define __array_ufunc__

3 participants