Skip to content

Commit

Permalink
Merge pull request #28007 from charris/backport-28005
Browse files Browse the repository at this point in the history
BUG: Cython API was missing NPY_UINTP.
  • Loading branch information
charris authored Dec 16, 2024
2 parents eb7071c + 4f82c32 commit 6219aeb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions numpy/__init__.cython-30.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ cdef extern from "numpy/arrayobject.h":
NPY_COMPLEX512

NPY_INTP
NPY_UINTP
NPY_DEFAULT_INT # Not a compile time constant (normally)!

ctypedef enum NPY_ORDER:
Expand Down
1 change: 1 addition & 0 deletions numpy/__init__.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ cdef extern from "numpy/arrayobject.h":
NPY_COMPLEX512

NPY_INTP
NPY_UINTP
NPY_DEFAULT_INT # Not a compile time constant (normally)!

ctypedef enum NPY_ORDER:
Expand Down
6 changes: 6 additions & 0 deletions numpy/_core/tests/examples/cython/checks.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,9 @@ def inc2_cfloat_struct(cnp.ndarray[cnp.cfloat_t] arr):
# This works in both modes
arr[1].real = arr[1].real + 1
arr[1].imag = arr[1].imag + 1


def check_npy_uintp_type_enum():
# Regression test for gh-27890: cnp.NPY_UINTP was not defined.
# Cython would fail to compile this before gh-27890 was fixed.
return cnp.NPY_UINTP > 0
6 changes: 6 additions & 0 deletions numpy/_core/tests/test_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,9 @@ def test_complex(install_temp):
arr = np.array([0, 10+10j], dtype="F")
inc2_cfloat_struct(arr)
assert arr[1] == (12 + 12j)


def test_npy_uintp_type_enum():
import checks
assert checks.check_npy_uintp_type_enum()

0 comments on commit 6219aeb

Please sign in to comment.