Skip to content

Commit 3fd3aee

Browse files
try fix windows
1 parent 366b3f5 commit 3fd3aee

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

sklearn_extra/robust/_robust_weighted_estimator_helper.pyx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import numpy as np
88
cimport numpy as np
99

1010
from sklearn.utils.extmath import row_norms
11+
from cython cimport floating
12+
1113
from libc.stdint cimport int32_t, int64_t
1214
# instead of int and long
1315

@@ -26,12 +28,12 @@ np.import_array()
2628
cdef floating _euclidean_dense_dense(
2729
floating* a, # IN
2830
floating* b, # IN
29-
int64_t n_features) nogil:
31+
int32_t n_features) nogil:
3032
"""Euclidean distance between a dense and b dense"""
3133
cdef:
32-
int64_t i
33-
int64_t n = n_features // 4
34-
int64_t rem = n_features % 4
34+
int32_t i
35+
int32_t n = n_features // 4
36+
int32_t rem = n_features % 4
3537
floating result = 0
3638

3739
# We manually unroll the loop for better cache optimization.
@@ -50,7 +52,7 @@ cdef floating _euclidean_dense_dense(
5052

5153

5254
cpdef np.ndarray[floating] _kmeans_loss(np.ndarray[floating, ndim=2, mode='c'] X,
53-
int64_t[:] labels):
55+
int32_t[:] labels):
5456
"""Compute inertia
5557
5658
squared distancez between each sample and its assigned center.
@@ -61,14 +63,14 @@ cpdef np.ndarray[floating] _kmeans_loss(np.ndarray[floating, ndim=2, mode='c'] X
6163
dtype = np.double
6264

6365
cdef:
64-
int64_t n_samples = X.shape[0]
65-
int64_t n_features = X.shape[1]
66-
int64_t i, j
67-
int64_t n_classes = len(np.unique(labels))
66+
int32_t n_samples = X.shape[0]
67+
int32_t n_features = X.shape[1]
68+
int32_t i, j
69+
int32_t n_classes = len(np.unique(labels))
6870
np.ndarray[floating, ndim=2] centers = np.zeros([n_classes,
6971
n_features],
7072
dtype = dtype)
71-
np.ndarray[long] num_in_cluster = np.zeros(n_classes, dtype = int64_t)
73+
np.ndarray[int64_t] num_in_cluster = np.zeros(n_classes, dtype = int32_t)
7274
np.ndarray[floating] inertias = np.zeros(n_samples, dtype = dtype)
7375
for i in range(n_samples):
7476
for j in range(n_features):

0 commit comments

Comments
 (0)