Skip to content
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

Upgrade to NumPy 2.0 #319

Merged
merged 11 commits into from
Jun 18, 2024
Merged

Upgrade to NumPy 2.0 #319

merged 11 commits into from
Jun 18, 2024

Conversation

dhermes
Copy link
Owner

@dhermes dhermes commented Jun 18, 2024

No description provided.

@dhermes dhermes force-pushed the dhermes/numpy-2.0 branch from e790da0 to 270b22c Compare June 18, 2024 05:51
@dhermes dhermes force-pushed the dhermes/numpy-2.0 branch from 270b22c to 88fe334 Compare June 18, 2024 05:56
@dhermes
Copy link
Owner Author

dhermes commented Jun 18, 2024

Note that https://github.com/cython/cython/blob/3.0.10/Cython/Includes/numpy/__init__.pxd still exists in latest Cython (3.0.10) but it's gone from the mainline branch: https://github.com/cython/cython/commits/master/Cython/Includes/numpy/__init__.pxd

But with NumPy 2.0, there is a problem with:

    /* "Cython/Includes/numpy/__init__.pxd":796
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 *     if PyDataType_HASSUBARRAY(d):
 *         return <tuple>d.subarray.shape             # <<<<<<<<<<<<<<
 *     else:
 *         return ()
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
    __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
    goto __pyx_L0;

In particular:

...
      src/python/bezier/_speedup.c:20608:39: error: ‘PyArray_Descr’ {aka ‘struct _PyArray_Descr’} has no member named ‘subarray’
      20608 |     __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
            |                                       ^~
...
      src/python/bezier/_speedup.c:20609:36: error: ‘PyArray_Descr’ {aka ‘struct _PyArray_Descr’} has no member named ‘subarray’
      20609 |     __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
            |                                    ^~

Comment on lines +51 to +52
__Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
__pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
Copy link
Owner Author

Choose a reason for hiding this comment

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

This is the problematic block; ->subarray is being invoked on a PyArray_Descr

Copy link
Owner Author

Choose a reason for hiding this comment

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

See #320 + cython/cython#6249 (comment), the resolution was straightforward!

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.

1 participant