1
1
#include <Python.h>
2
2
3
3
#define PY_ARRAY_UNIQUE_SYMBOL metadatadtype_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 "umath.h"
13
14
14
15
static int
15
16
translate_given_descrs (int nin , int nout ,
16
- PyArray_DTypeMeta * NPY_UNUSED (wrapped_dtypes []),
17
- PyArray_Descr * given_descrs [],
17
+ PyArray_DTypeMeta * const NPY_UNUSED (wrapped_dtypes []),
18
+ PyArray_Descr * const given_descrs [],
18
19
PyArray_Descr * new_descrs [])
19
20
{
20
21
for (int i = 0 ; i < nin + nout ; i ++ ) {
@@ -35,8 +36,8 @@ translate_given_descrs(int nin, int nout,
35
36
36
37
static int
37
38
translate_loop_descrs (int nin , int NPY_UNUSED (nout ),
38
- PyArray_DTypeMeta * NPY_UNUSED (new_dtypes []),
39
- PyArray_Descr * given_descrs [],
39
+ PyArray_DTypeMeta * const NPY_UNUSED (new_dtypes []),
40
+ PyArray_Descr * const given_descrs [],
40
41
PyArray_Descr * original_descrs [],
41
42
PyArray_Descr * loop_descrs [])
42
43
{
@@ -102,9 +103,11 @@ add_wrapping_loop(const char *ufunc_name, PyArray_DTypeMeta **dtypes,
102
103
return res ;
103
104
}
104
105
105
- int
106
- init_ufuncs (void )
106
+ PyObject *
107
+ init_ufuncs (PyObject * module )
107
108
{
109
+ import_umath ();
110
+
108
111
PyArray_DTypeMeta * binary_orig_dtypes [3 ] = {& MetadataDType , & MetadataDType ,
109
112
& MetadataDType };
110
113
PyArray_DTypeMeta * binary_wrapped_dtypes [3 ] = {
@@ -123,7 +126,9 @@ init_ufuncs(void)
123
126
goto error ;
124
127
}
125
128
126
- return 0 ;
129
+ return module ;
127
130
error :
128
- return -1 ;
131
+
132
+ Py_DECREF (module );
133
+ return NULL ;
129
134
}
0 commit comments