142
142
# BinaryTree tree2, ITYPE_t i_node2):
143
143
# """Compute the maximum distance between two nodes"""
144
144
145
- cimport numpy as np
145
+ cimport numpy as cnp
146
146
from libc .math cimport fabs , sqrt , exp , cos , pow , log , lgamma
147
147
from libc .math cimport fmin , fmax
148
148
from libc .stdlib cimport calloc , malloc , free
@@ -167,9 +167,9 @@ from ..utils._heap cimport heap_push
167
167
from ..utils ._sorting cimport simultaneous_sort as _simultaneous_sort
168
168
169
169
cdef extern from "numpy/arrayobject.h" :
170
- void PyArray_ENABLEFLAGS (np .ndarray arr , int flags )
170
+ void PyArray_ENABLEFLAGS (cnp .ndarray arr , int flags )
171
171
172
- np .import_array ()
172
+ cnp .import_array ()
173
173
174
174
# some handy constants
175
175
cdef DTYPE_t INF = np .inf
@@ -509,8 +509,8 @@ cdef class NeighborsHeap:
509
509
n_nbrs : int
510
510
the size of each heap.
511
511
"""
512
- cdef np .ndarray distances_arr
513
- cdef np .ndarray indices_arr
512
+ cdef cnp .ndarray distances_arr
513
+ cdef cnp .ndarray indices_arr
514
514
515
515
cdef DTYPE_t [:, ::1 ] distances
516
516
cdef ITYPE_t [:, ::1 ] indices
@@ -641,7 +641,7 @@ cdef class NodeHeap:
641
641
642
642
heap[i].val < min(heap[2 * i + 1].val, heap[2 * i + 2].val)
643
643
"""
644
- cdef np .ndarray data_arr
644
+ cdef cnp .ndarray data_arr
645
645
cdef NodeHeapData_t [::1 ] data
646
646
cdef ITYPE_t n
647
647
@@ -662,7 +662,7 @@ cdef class NodeHeap:
662
662
cdef NodeHeapData_t * new_data_ptr
663
663
cdef ITYPE_t i
664
664
cdef ITYPE_t size = self .data .shape [0 ]
665
- cdef np .ndarray new_data_arr = np .zeros (new_size ,
665
+ cdef cnp .ndarray new_data_arr = np .zeros (new_size ,
666
666
dtype = NodeHeapData )
667
667
cdef NodeHeapData_t [::1 ] new_data = new_data_arr
668
668
@@ -767,11 +767,11 @@ VALID_METRIC_IDS = get_valid_metric_ids(VALID_METRICS)
767
767
# Binary Tree class
768
768
cdef class BinaryTree :
769
769
770
- cdef np .ndarray data_arr
771
- cdef np .ndarray sample_weight_arr
772
- cdef np .ndarray idx_array_arr
773
- cdef np .ndarray node_data_arr
774
- cdef np .ndarray node_bounds_arr
770
+ cdef cnp .ndarray data_arr
771
+ cdef cnp .ndarray sample_weight_arr
772
+ cdef cnp .ndarray idx_array_arr
773
+ cdef cnp .ndarray node_data_arr
774
+ cdef cnp .ndarray node_bounds_arr
775
775
776
776
cdef readonly const DTYPE_t [:, ::1 ] data
777
777
cdef readonly const DTYPE_t [::1 ] sample_weight
@@ -1336,16 +1336,16 @@ cdef class BinaryTree:
1336
1336
distances_npy = np .zeros (Xarr .shape [0 ], dtype = 'object' )
1337
1337
for i in range (Xarr .shape [0 ]):
1338
1338
# make a new numpy array that wraps the existing data
1339
- indices_npy [i ] = np .PyArray_SimpleNewFromData (1 , & counts [i ], np .NPY_INTP , indices [i ])
1339
+ indices_npy [i ] = cnp .PyArray_SimpleNewFromData (1 , & counts [i ], cnp .NPY_INTP , indices [i ])
1340
1340
# make sure the data will be freed when the numpy array is garbage collected
1341
- PyArray_ENABLEFLAGS (indices_npy [i ], np .NPY_OWNDATA )
1341
+ PyArray_ENABLEFLAGS (indices_npy [i ], cnp .NPY_OWNDATA )
1342
1342
# make sure the data is not freed twice
1343
1343
indices [i ] = NULL
1344
1344
1345
1345
# make a new numpy array that wraps the existing data
1346
- distances_npy [i ] = np .PyArray_SimpleNewFromData (1 , & counts [i ], np .NPY_DOUBLE , distances [i ])
1346
+ distances_npy [i ] = cnp .PyArray_SimpleNewFromData (1 , & counts [i ], cnp .NPY_DOUBLE , distances [i ])
1347
1347
# make sure the data will be freed when the numpy array is garbage collected
1348
- PyArray_ENABLEFLAGS (distances_npy [i ], np .NPY_OWNDATA )
1348
+ PyArray_ENABLEFLAGS (distances_npy [i ], cnp .NPY_OWNDATA )
1349
1349
# make sure the data is not freed twice
1350
1350
distances [i ] = NULL
1351
1351
@@ -1356,9 +1356,9 @@ cdef class BinaryTree:
1356
1356
indices_npy = np .zeros (Xarr .shape [0 ], dtype = 'object' )
1357
1357
for i in range (Xarr .shape [0 ]):
1358
1358
# make a new numpy array that wraps the existing data
1359
- indices_npy [i ] = np .PyArray_SimpleNewFromData (1 , & counts [i ], np .NPY_INTP , indices [i ])
1359
+ indices_npy [i ] = cnp .PyArray_SimpleNewFromData (1 , & counts [i ], cnp .NPY_INTP , indices [i ])
1360
1360
# make sure the data will be freed when the numpy array is garbage collected
1361
- PyArray_ENABLEFLAGS (indices_npy [i ], np .NPY_OWNDATA )
1361
+ PyArray_ENABLEFLAGS (indices_npy [i ], cnp .NPY_OWNDATA )
1362
1362
# make sure the data is not freed twice
1363
1363
indices [i ] = NULL
1364
1364
0 commit comments