Skip to content

Add getter for NumPy ufunc types to patching#226

Merged
ndgrigorian merged 3 commits into
mainfrom
fix-for-numpy-2.5
Jun 29, 2026
Merged

Add getter for NumPy ufunc types to patching#226
ndgrigorian merged 3 commits into
mainfrom
fix-for-numpy-2.5

Conversation

@ndgrigorian

Copy link
Copy Markdown
Collaborator

NumPy 2.5 has changed how types property is exposed with ufunc.types. This caused mkl_umath to crash during patching on pre-release NumPy.

This PR adds a getter, _get_ufunc_types, defined in _patch_numpy.pyx as cdef extern. This getter works with NumPy 2.5 and previous versions by accessing the ufunc struct directly.

Additionally, slips in changes which prevent attempting free of nullptr when the patch fails (i.e., due to RuntimeError).

jharlow-intel
jharlow-intel previously approved these changes Jun 11, 2026

@jharlow-intel jharlow-intel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@antonwolfy antonwolfy added this to the 0.5.0 release milestone Jun 12, 2026
Comment thread mkl_umath/src/_patch_numpy.pyx Outdated
Comment thread mkl_umath/src/_patch_numpy.pyx Outdated
Comment thread mkl_umath/src/_patch_numpy.pyx
Comment thread mkl_umath/src/_patch_numpy.pyx Outdated
NumPy 2.5+ changed how types property is exposed in NumPy, causing indexing on the types to break

also fixes a bug where patching would attempt to free null pointers when patching process fails midway

@antonwolfy antonwolfy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you @ndgrigorian

@ndgrigorian ndgrigorian merged commit d15aea4 into main Jun 29, 2026
57 of 72 checks passed
@ndgrigorian ndgrigorian deleted the fix-for-numpy-2.5 branch June 29, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants