DEP: Shift correlate mode parsing to C and deprecate inexact matches#17492
DEP: Shift correlate mode parsing to C and deprecate inexact matches#17492mattip merged 8 commits intonumpy:mainfrom
Conversation
eric-wieser
left a comment
There was a problem hiding this comment.
Thanks for the contribution, although this isn't quite right.
I'd actually be very tempted to move this parameter parsing to C, so that it can be handled in exactly the same way as the other arguments like this. Would you be ok to try that instead?
rossbar
left a comment
There was a problem hiding this comment.
Agreed - the deprecation should not change the behavior, but warn the user that the behavior will change when the deprecation expires.
A few comments on the tests as well since I had looked at them.
f177eef to
7708fe1
Compare
|
Close/reopen to restart builds |
rossbar
left a comment
There was a problem hiding this comment.
This change still results in modified behavior. For example, on master np.convolve(*args, mode="silly") will result in mode 1 being used, whereas in the PR, the same call will result in 2. The deprecation should only warn the user of a pending behavior change, not silently change the behavior.
I would recommend getting rid of the default_mode addition and see if you can come up with a minimal change for raising the warning.
I raised this question here: #17492 (comment) |
7708fe1 to
b3f86f9
Compare
|
I think my comment above might have gotten lost:
|
I actually missed it amid suggestions. I wouldn't mind, could you point me to a right path to start digging in? |
|
Sure, here's some pointers: The code that parses the numpy/numpy/core/src/multiarray/multiarraymodule.c Lines 2897 to 2909 in 565fe77 My suggestion would be to change that to something like: where numpy/numpy/core/src/multiarray/conversion_utils.c Lines 598 to 673 in 565fe77 |
b3f86f9 to
4dbc544
Compare
|
Hey @eric-wieser I could use some help here. It took me a while but I was able to shift parameter parsing completely to C, it worked well locally until I did something wrong during the last few changes - build is failing (KeyError of the function name). I'm thinking I should add a Global C Pointer key value in numpy_api? I've incorporated your suggestion, and haven't changed the behaviour. (You can still review the changes, the build error should be solvable) |
9cf6fb9 to
e811a8f
Compare
|
The build works locally, should be fine for review now. 👍🏼 |
e811a8f to
0cc1285
Compare
04cb219 to
6e417cb
Compare
numpy/core/tests/test_numeric.py
Outdated
There was a problem hiding this comment.
Can you add a test of an invalid integer too?
Also, it may make sense to add a test here too:
numpy/numpy/core/src/multiarray/_multiarray_tests.c.src
Lines 2088 to 2101 in aeb2374
numpy/numpy/core/src/multiarray/_multiarray_tests.c.src
Lines 2308 to 2310 in aeb2374
numpy/numpy/core/tests/test_conversion_utils.py
Lines 163 to 174 in aeb2374
There was a problem hiding this comment.
I created the tests, but I can't seem to find a way to make PyArray_CorrelatemodeConverter function visible like PyArray_ClipmodeConverter in this file:
numpy/numpy/core/src/multiarray/_multiarray_tests.c.src
Lines 2088 to 2101 in aeb2374
If I directly #include "conversion_utils.h" it throws a bunch of errors while building, which is understandable.
I think PyArray_ClipmodeConverter is visible to this file as it is a global C API.
Or is there something I'm missing?
There was a problem hiding this comment.
I think
PyArray_ClipmodeConverteris visible to this file as it is a global C API.
Hmm, that's possible.
If I directly #include "conversion_utils.h" it throws a bunch of errors while building, which is understandable.
Can you give an example of those errors?
There was a problem hiding this comment.
Here's the full traceback, it seems like a compiler issue?
In file included from numpy/core/include/numpy/ndarrayobject.h:21:0,
from numpy/core/include/numpy/arrayobject.h:4,
from numpy/core/src/multiarray/_multiarray_tests.c.src:5:
numpy/core/include/numpy/__multiarray_api.h:1090:12: error: expected identifier or ‘(’ before ‘int’
(*(int (*)(PyObject *, PyArray_Dims *)) \
^
numpy/core/src/multiarray/conversion_utils.h:7:1: note: in expansion of macro ‘PyArray_IntpConverter’
PyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq);
^~~~~~~~~~~~~~~~~~~~~
numpy/core/include/numpy/__multiarray_api.h:1445:10: error: expected ‘)’ before ‘PyArray_API’
PyArray_API[298])
^
numpy/core/src/multiarray/conversion_utils.h:49:1: note: in expansion of macro ‘PyArray_SelectkindConverter’
PyArray_SelectkindConverter(PyObject *obj, NPY_SELECTKIND *selectkind);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
There was a problem hiding this comment.
Yeah, looks like your diagnosis is correct; multiarray_tests requires things to be in the public API. I think it's ok to leave things as is for now, thanks for investigating
6e417cb to
5fe981e
Compare
|
All builds pass successfully, think we can merge it now? |
|
/cc @eric-wieser @rossbar |
eric-wieser
left a comment
There was a problem hiding this comment.
This ought to have a release note too - sorry for forgetting about this for so long!
That's completely fine :) |
|
@eric-wieser Do you want me to squash the commits? |
|
@eric-wieser could you take one last look? |
|
@aitikgupta this PR was approved but seems to have gotten lost. Now there are merge conflicts. Could you merge with main or rebase it to clear the path for merging it? @eric-wieser any need for more review? |
|
I don't think this needs any more review; just the merge conflicts resolving after the argument parsing change |
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
80def6f to
89de3d9
Compare
|
rebased to clear merge conflicts |
@mattip did the heavy lifting before I could jump in :D |
|
Thanks @aitikgupta, sorry it took so long to get this merged. |
Fixes #17476
Also, see #16056