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
make tests run on numpy1.x and numpy2.x #6076
Conversation
This is better but it does not fix everything. There is some mess since on NumPy1
but on NumPy2
This is making compilation fail since cython assumes |
There is no simple way to map |
I think dropping Not sure what to do about the complex stuff. There probably isn't a sensible way of writing one test for Cython that covers both (because the interface has changed, and what we're really testing in Cython is the interface) |
I think cython should wait for a resolution to numpy/numpy#26029, and adjust the tests appropriately. Clearly In any case, this PR goes most of the way to fixing the incompatibility in a way that works on both versions, so if CI agrees maybe it could be merged and the rest handled in a subsequent PR. |
CI is passing. |
Yeah I think I'm happy to go along with this. I'll put off a decision about backporting it to now and just merge it to master I think. Thanks @mattip |
* make tests run on numpy1.x and numpy2.x * more casting to fix NumPy1/NumPy2 compatibility * On NumPy2, int_t is now int64_t * remove test for np.int_
3.0.x commit e4b1e5e (since it looks like the Python 3.12 tests there use Numpy 2) |
@@ -22,7 +22,7 @@ def test_parallel_numpy_arrays(): | |||
4 | |||
""" | |||
cdef Py_ssize_t i, length | |||
cdef np.ndarray[np.int_t] x | |||
cdef np.ndarray[np.int64_t] x |
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.
On numpy 1.26.0 on i686 this test fails with:
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python3.12/doctest.py", line 1361, in __run
exec(compile(example.source, filename, "single",
File "<doctest numpy_parallel.test_parallel_numpy_arrays[0]>", line 1, in <module>
test_parallel_numpy_arrays()
File "tests/run/numpy_parallel.pyx", line 34, in numpy_parallel.test_parallel_numpy_arrays (numpy_parallel.c:4494)
x = numpy.zeros(10, dtype=numpy.int_)
ValueError: Buffer dtype mismatch, expected 'int64_t' but got 'long'
Fixes #6072
Should this also add a numpy2.0b1 test run to CI via the wheels at https://pypi.anaconda.org/scientific-python-nightly-wheels/numpy (i.e. install numpy via this index)?
Edit: make it a question