Skip to content

Commit 8ae5f18

Browse files
authored
MAINT Add numpy.import_array where missing (scikit-learn#27532)
1 parent 206769c commit 8ae5f18

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

sklearn/cluster/_hdbscan/_linkage.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ from ...cluster._hdbscan._tree cimport HIERARCHY_t
4141
from ...cluster._hdbscan._tree import HIERARCHY_dtype
4242
from ...utils._typedefs cimport intp_t, float64_t, int64_t, uint8_t
4343

44+
cnp.import_array()
45+
4446
cdef extern from "numpy/arrayobject.h":
4547
intp_t * PyArray_SHAPE(cnp.PyArrayObject *)
4648

sklearn/cluster/_hdbscan/_tree.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import cython
3636

3737
import numpy as np
3838

39+
cnp.import_array()
40+
3941
cdef extern from "numpy/arrayobject.h":
4042
intp_t * PyArray_SHAPE(cnp.PyArrayObject *)
4143

sklearn/manifold/_utils.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ from libc cimport math
22
import numpy as np
33
cimport numpy as cnp
44

5+
cnp.import_array()
6+
57

68
cdef extern from "numpy/npy_math.h":
79
float NPY_INFINITY

sklearn/metrics/cluster/_expected_mutual_info_fast.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ from scipy.special import gammaln
77
import numpy as np
88
cimport numpy as cnp
99

10+
cnp.import_array()
11+
1012

1113
def expected_mutual_information(contingency, cnp.int64_t n_samples):
1214
"""Calculate the expected mutual information for two labelings."""

sklearn/tree/_splitter.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ from ._utils cimport rand_int
2929
from ._utils cimport rand_uniform
3030
from ._utils cimport RAND_R_MAX
3131

32+
cnp.import_array()
33+
3234
cdef double INFINITY = np.inf
3335

3436
# Mitigate precision differences between 32 bit and 64 bit

0 commit comments

Comments
 (0)