Skip to content

Commit feee36d

Browse files
erglarsmans
authored andcommitted
FIX: Cast floats to int before slicing in robust_covariance
Fixes scikit-learn#1608.
1 parent 07c56d7 commit feee36d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sklearn/covariance/robust_covariance.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ def fast_mcd(X, support_fraction=None,
365365
n_subsets = n_samples // 300
366366
n_samples_subsets = n_samples // n_subsets
367367
samples_shuffle = random_state.permutation(n_samples)
368-
h_subset = np.ceil(n_samples_subsets * (n_support / float(n_samples)))
368+
h_subset = int(np.ceil(n_samples_subsets *
369+
(n_support / float(n_samples))))
369370
# b. perform a total of 500 trials
370371
n_trials_tot = 500
371372
# c. select 10 best (location, covariance) for each subset
@@ -398,7 +399,8 @@ def fast_mcd(X, support_fraction=None,
398399
## 2. Pool the candidate supports into a merged set
399400
## (possibly the full dataset)
400401
n_samples_merged = min(1500, n_samples)
401-
h_merged = np.ceil(n_samples_merged * (n_support / float(n_samples)))
402+
h_merged = int(np.ceil(n_samples_merged *
403+
(n_support / float(n_samples))))
402404
if n_samples > 1500:
403405
n_best_merged = 10
404406
else:

0 commit comments

Comments
 (0)