Skip to content

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Jan 23, 2018

This behaves exactly as before

Part of the cleanup needed to fix #10450

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Only a question about whether you'd not rather check for a tuple here as well. Fine to do that in a follow-up PR, though.

@@ -243,27 +269,13 @@ _find_array_prepare(PyObject *args, PyObject *kwds,
obj = PyDict_GetItem(kwds, npy_um_str_out);
Copy link
Contributor

Choose a reason for hiding this comment

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

You are on purpose not yet checking whether the out argument is a tuple, correct?

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'm on purpose just leaving it as it was - I want to push the out argument parsing way upstream

@eric-wieser
Copy link
Member Author

Actually, I should try to keep the comments from the function I removed - so don't merge this yet

@eric-wieser eric-wieser force-pushed the func_lookup_deduplicate branch from 326ac85 to ee0a016 Compare January 24, 2018 05:07
@eric-wieser
Copy link
Member Author

Updated with comments and slightly more efficient code.

static PyObject *
_get_output_array_method(PyObject *obj, PyObject *method,
PyObject *input_method) {
if (obj == Py_None) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There are now three times in which you have the incref and return of input_method. How about inverting the logic, and move the next two lines to the very end, as the fall-back opion, i.e.,

PyObject *ometh;
if obj != Py_None` {
    if (PyArrayCheckExact(obj)) {
        return Py_RETURN_NONE;
    }
    ometh = ...
    if (ometh) {
        if(PyCallable_Check(ometh)) {
            return ometh;
        }
        else {
            Py_DECREF(ometh);
        }
    }
    else {
        PyErr_Clear();
    }
}
Py_XINCREF(input_method);
return input_method;

@eric-wieser eric-wieser force-pushed the func_lookup_deduplicate branch from ee0a016 to e6956dd Compare January 24, 2018 17:35
@eric-wieser
Copy link
Member Author

Should be ready

@mhvk
Copy link
Contributor

mhvk commented Jan 25, 2018

All OK now, merging!

@mhvk mhvk merged commit 9404833 into numpy:master Jan 25, 2018
eric-wieser added a commit to eric-wieser/numpy that referenced this pull request Jan 26, 2018
…lt to inherit the output's mask

This brings `np.add(a, b, out)` in line with  `np.add(a, b, out=out)`.
These previously differed because numpygh-10459 causes them to call __array_wrap__ in different ways (with and without the output argument in the context tuple, respectively).

Since the data in the `out` argument is never used by ufuncs, it seems consistent that the mask should not be either.
charris pushed a commit to charris/numpy that referenced this pull request Feb 9, 2018
Currently, this causes the result to inherit the output's mask.

This brings `np.add(a, b, out)` in line with  `np.add(a, b, out=out)`.
These previously differed because numpygh-10459 causes them to call
__array_wrap__ in different ways (with and without the output argument
in the context tuple, respectively).

Since the data in the `out` argument is never used by ufuncs, it seems
consistent that the mask should not be either.
hanjohn pushed a commit to hanjohn/numpy that referenced this pull request Feb 15, 2018
…lt to inherit the output's mask

This brings `np.add(a, b, out)` in line with  `np.add(a, b, out=out)`.
These previously differed because numpygh-10459 causes them to call __array_wrap__ in different ways (with and without the output argument in the context tuple, respectively).

Since the data in the `out` argument is never used by ufuncs, it seems consistent that the mask should not be either.
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.

2 participants