Skip to content

Commit ab2f5e9

Browse files
authored
Merge pull request numpy#27202 from seberg/issue-27194
BUG: Fix NPY_RAVEL_AXIS on backwards compatible NumPy 2 builds
2 parents be296e2 + 7e88f59 commit ab2f5e9

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

numpy/_core/include/numpy/npy_2_compat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ PyArray_ImportNumPyAPI(void)
125125
#define NPY_DEFAULT_INT \
126126
(PyArray_RUNTIME_VERSION >= NPY_2_0_API_VERSION ? NPY_INTP : NPY_LONG)
127127
#define NPY_RAVEL_AXIS \
128-
(PyArray_RUNTIME_VERSION >= NPY_2_0_API_VERSION ? -1 : 32)
128+
(PyArray_RUNTIME_VERSION >= NPY_2_0_API_VERSION ? NPY_MIN_INT : 32)
129129
#define NPY_MAXARGS \
130130
(PyArray_RUNTIME_VERSION >= NPY_2_0_API_VERSION ? 64 : 32)
131131
#endif

numpy/_core/tests/examples/cython/checks.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ def get_default_integer():
129129
return cnp.dtype("intp")
130130
return None
131131

132+
def get_ravel_axis():
133+
return cnp.NPY_RAVEL_AXIS
134+
135+
132136
def conv_intp(cnp.intp_t val):
133137
return val
134138

numpy/_core/tests/test_cython.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ def test_default_int(install_temp):
153153

154154
assert checks.get_default_integer() is np.dtype(int)
155155

156+
157+
def test_ravel_axis(install_temp):
158+
import checks
159+
160+
assert checks.get_ravel_axis() == np.iinfo("intc").min
161+
162+
156163
def test_convert_datetime64_to_datetimestruct(install_temp):
157164
# GH#21199
158165
import checks

0 commit comments

Comments
 (0)