-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
ENH/MAINT: ndimage: implement LineBufferIterator
class and wrappers.
#7569
base: main
Are you sure you want to change the base?
Conversation
There's no need for a detailed review of this code, this PR will be closed without merging. I'm mostly after comments on the general direction this is moving. |
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.
Jaime, thanks for working on improving the ndimage API. I completely trust your intuition on the best direction to take the code; we can't really go wrong either (it would take a lot to make the API worse ;).
npy_intp size_before, npy_intp size_after, | ||
npy_double unused_value) | ||
{ | ||
/* abcddcba|abcd|dcbaabcd */ |
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.
This comment and the one in the function below are the same.
I remember there were issues with one of these, but not with which one.
Maybe not worth fixing if this PR is going to be closed, but just pointing out that the failures here are real:
Didn't look at why it only happens on a couple of the build configs. |
|
||
|
||
LineBufferIterator* | ||
LBI_New(PyArrayObject *input, int axis, PyArrayObject *output, |
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.
Better rename this to something that doesn't have new
in it - that usually doesn't make sense a few years after introduction.
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.
This one is so good it will always feel like new... ;-)
It's supposed to be new
as in new
and delete
in C++, i.e. the "class" constructor. It's inspired by the numpy iterator's NpyIter_New
.
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.
Ah, that makes more sense:)
That looks like a good plan to me. The |
The failures are in Python 3, I did not add the |
c7a7575
to
8c6d0c1
Compare
LineBufferIterator
class and wrappers.
DO NOT MERGE
This is pretty large PR, with a proof of concept of the way I would like to refactor
ndimage
. It includes:An implementation of
NDIterator
(very similar toNI_Iterator
) andLineBufferIterator
(somewhat similar toNI_LineBuffer
), spread over three files (ni_iterators.h
,ni_iterators.c
andni_iterator_utils.c
). Note that the exposed API, seeni_iterators.h
, is pretty small compared to the equivalent existing objects.A Python wrapper for the
LineBufferIterator
object, seeni_iterator_pywrap.c
. This would not be meant to be exposed to the user (the implementation right now is not very safe), but to enable in depth testing of the C code. As an example some tests have been added intest_ni_iterators.py
.An implementation of the
uniform_filter1D
function using these new iterators, also inni_iterator_pywrap.c
. This was done to demonstrate that:I have used C in the last two points mostly for my convenience, but if we can agree that this is the right path forward, I would propose to:
ni_filters.c
that would use the newLineBufferIterator
.NI_FilterIterator
, although the details for that are still TBD.