-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
ENH: Add an out argument to concatenate #9209
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
Conversation
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.
Arguably we might now want a casting
argument as well
} | ||
Py_INCREF(ret); | ||
} |
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.
Only real change here is this if
statement
} | ||
Py_INCREF(ret); | ||
} |
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.
And this if statement
PyArray_Concatenate(PyObject *op, int axis) | ||
{ | ||
return PyArray_ConcatenateInto(op, axis, NULL); | ||
} |
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.
And here we just redirect the old API to not break compatibility
909b411
to
b7bee01
Compare
Seems pretty useful to me. There are definitely times where I've wanted to do such an operation and resorted to doing it by hand in a loop over a statement like Code LGTM. |
b7bee01
to
670e5b4
Compare
Tests and release note added. I've left out I'll leave |
670e5b4
to
a8a4045
Compare
Rebased to fix release note clashes. @ahaldane, good to merge? |
* the memory layout of the input arrays, using ambiguity | ||
* resolution rules matching that of the NpyIter. | ||
*/ | ||
PyArray_CreateMultiSortedStridePerm(narrays, arrays, ndim, strideperm); |
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.
incidentally, this is the only place in numpy this function is used.
For a second I thought there might be some problem that we ignore strides when out is provided, like in #7633, but it's fine, PyArray_AssignArray
below is insensitive to order.
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.
Yeah, I assume this is an optimization
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.
I remember this function being new in 1.7 or so, somewhat thought it was used with the new iterator, but maybe there was some change there (since I also remember there was a some bug with this or its usage). The idea is simple though, find the cache friendliest iteration order....
The tests need to be reworked, not sure what happened to Code LGTM again. Also, we might use the new priority function in #9672 too. Actually, a lot of the the |
a8a4045
to
0228ebf
Compare
Fixed to use |
OK, will merge this soon too. |
Merging, thanks Eric |
oh, sorry, the page just refreshed and there's a release note conflict you need to fix. |
Ok, merged through the web interface, since rebasing causes a mess due to the |
Thanks for the quick fix, merging for real now. |
Useful for: