@@ -12,13 +12,6 @@ from libcpp.map cimport map as cpp_map
12
12
13
13
import numpy as np
14
14
15
- # Import the C-level symbols of numpy
16
- cimport numpy as cnp
17
-
18
- # Numpy must be initialized. When using numpy from C or Cython you must
19
- # _always_ do that, or you will have segfaults
20
- cnp.import_array()
21
-
22
15
# DTYPE = np.float64
23
16
# ctypedef cnp.float64_t DTYPE_t
24
17
@@ -35,8 +28,11 @@ cnp.import_array()
35
28
36
29
cdef class IntFloatDict:
37
30
38
- def __init__ (self , cnp.ndarray[ITYPE_t , ndim = 1 ] keys,
39
- cnp.ndarray[DTYPE_t , ndim = 1 ] values):
31
+ def __init__ (
32
+ self ,
33
+ ITYPE_t[:] keys ,
34
+ DTYPE_t[:] values ,
35
+ ):
40
36
cdef int i
41
37
cdef int size = values.size
42
38
# Should check that sizes for keys and values are equal, and
@@ -91,10 +87,8 @@ cdef class IntFloatDict:
91
87
The values of the data points
92
88
"""
93
89
cdef int size = self .my_map.size()
94
- cdef cnp.ndarray[ITYPE_t, ndim= 1 ] keys = np.empty(size,
95
- dtype = np.intp)
96
- cdef cnp.ndarray[DTYPE_t, ndim= 1 ] values = np.empty(size,
97
- dtype = np.float64)
90
+ keys = np.empty(size, dtype = np.intp)
91
+ values = np.empty(size, dtype = np.float64)
98
92
self ._to_arrays(keys, values)
99
93
return keys, values
100
94
0 commit comments