Skip to content

Commit 366b3f5

Browse files
try lon long fix windows
1 parent 668a3d6 commit 366b3f5

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

sklearn_extra/robust/_robust_weighted_estimator_helper.pyx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import numpy as np
88
cimport numpy as np
99

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

1315
import sys
1416
from time import time
@@ -24,12 +26,12 @@ np.import_array()
2426
cdef floating _euclidean_dense_dense(
2527
floating* a, # IN
2628
floating* b, # IN
27-
int n_features) nogil:
29+
int64_t n_features) nogil:
2830
"""Euclidean distance between a dense and b dense"""
2931
cdef:
30-
int i
31-
int n = n_features // 4
32-
int rem = n_features % 4
32+
int64_t i
33+
int64_t n = n_features // 4
34+
int64_t rem = n_features % 4
3335
floating result = 0
3436

3537
# We manually unroll the loop for better cache optimization.
@@ -48,7 +50,7 @@ cdef floating _euclidean_dense_dense(
4850

4951

5052
cpdef np.ndarray[floating] _kmeans_loss(np.ndarray[floating, ndim=2, mode='c'] X,
51-
int[:] labels):
53+
int64_t[:] labels):
5254
"""Compute inertia
5355
5456
squared distancez between each sample and its assigned center.
@@ -59,14 +61,14 @@ cpdef np.ndarray[floating] _kmeans_loss(np.ndarray[floating, ndim=2, mode='c'] X
5961
dtype = np.double
6062

6163
cdef:
62-
int n_samples = X.shape[0]
63-
int n_features = X.shape[1]
64-
int i, j
65-
int n_classes = len(np.unique(labels))
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))
6668
np.ndarray[floating, ndim=2] centers = np.zeros([n_classes,
6769
n_features],
6870
dtype = dtype)
69-
np.ndarray[long] num_in_cluster = np.zeros(n_classes, dtype = int)
71+
np.ndarray[long] num_in_cluster = np.zeros(n_classes, dtype = int64_t)
7072
np.ndarray[floating] inertias = np.zeros(n_samples, dtype = dtype)
7173
for i in range(n_samples):
7274
for j in range(n_features):

0 commit comments

Comments
 (0)