1
1
#include <Python.h>
2
2
3
3
#define PY_ARRAY_UNIQUE_SYMBOL asciidtype_ARRAY_API
4
- #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
4
+ #define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION
5
+ #define NPY_TARGET_VERSION NPY_2_0_API_VERSION
5
6
#define NO_IMPORT_ARRAY
6
- #include "numpy/arrayobject.h"
7
- #include "numpy/experimental_dtype_api.h"
8
7
#include "numpy/ndarraytypes.h"
8
+ #include "numpy/arrayobject.h"
9
9
#include "numpy/ufuncobject.h"
10
+ #include "numpy/dtype_api.h"
10
11
11
12
#include "dtype.h"
12
13
#include "string.h"
@@ -17,7 +18,7 @@ ascii_add_strided_loop(PyArrayMethod_Context *context, char *const data[],
17
18
npy_intp const dimensions [], npy_intp const strides [],
18
19
NpyAuxData * NPY_UNUSED (auxdata ))
19
20
{
20
- PyArray_Descr * * descrs = context -> descriptors ;
21
+ PyArray_Descr * const * descrs = context -> descriptors ;
21
22
long in1_size = ((ASCIIDTypeObject * )descrs [0 ])-> size ;
22
23
long in2_size = ((ASCIIDTypeObject * )descrs [1 ])-> size ;
23
24
long out_size = ((ASCIIDTypeObject * )descrs [2 ])-> size ;
@@ -112,7 +113,7 @@ ascii_equal_strided_loop(PyArrayMethod_Context *context, char *const data[],
112
113
npy_intp const dimensions [], npy_intp const strides [],
113
114
NpyAuxData * NPY_UNUSED (auxdata ))
114
115
{
115
- PyArray_Descr * * descrs = context -> descriptors ;
116
+ PyArray_Descr * const * descrs = context -> descriptors ;
116
117
long in1_size = ((ASCIIDTypeObject * )descrs [0 ])-> size ;
117
118
long in2_size = ((ASCIIDTypeObject * )descrs [1 ])-> size ;
118
119
@@ -218,12 +219,14 @@ init_equal_ufunc(PyObject *numpy)
218
219
return 0 ;
219
220
}
220
221
221
- int
222
+ PyObject *
222
223
init_ufuncs (void )
223
224
{
225
+ import_umath ();
226
+
224
227
PyObject * numpy = PyImport_ImportModule ("numpy" );
225
228
if (numpy == NULL ) {
226
- return -1 ;
229
+ return NULL ;
227
230
}
228
231
229
232
if (init_add_ufunc (numpy ) < 0 ) {
@@ -234,10 +237,9 @@ init_ufuncs(void)
234
237
goto error ;
235
238
}
236
239
237
- Py_DECREF (numpy );
238
- return 0 ;
240
+ return numpy ;
239
241
240
242
error :
241
243
Py_DECREF (numpy );
242
- return -1 ;
244
+ return NULL ;
243
245
}
0 commit comments