8000 accept both float types where possible, be explicit otherwise · scikit-learn/scikit-learn@70a65d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 70a65d4

Browse files
committed
accept both float types where possible, be explicit otherwise
1 parent df02a39 commit 70a65d4

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

sklearn/cluster/spectral.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@ def fit(self, X):
415415
OR, if affinity==`precomputed`, a precomputed affinity
416416
matrix of shape (n_samples, n_samples)
417417
"""
418-
X = check_array(X, accept_sparse=['csr', 'csc', 'coo'], dtype=np.float)
418+
X = check_array(X, accept_sparse=['csr', 'csc', 'coo'],
419+
dtype=np.float64)
419420
if X.shape[0] == X.shape[1] and self.affinity != "precomputed":
420421
warnings.warn("The spectral clustering API has changed. ``fit``"
421422
"now constructs an affinity matrix from data. To use"

sklearn/linear_model/coordinate_descent.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ def enet_path(X, y, l1_ratio=0.5, eps=1e-3, n_alphas=100, alphas=None,
348348
ElasticNetCV
349349
"""
350350
X = check_array(X, 'csc', dtype=np.float64, order='F', copy=copy_X)
351+
if Xy is not None:
352+
Xy = check_array(Xy, 'csc', dtype=np.float64, order='F', copy=False,
353+
ensure_2d=False)
351354
n_samples, n_features = X.shape
352355

353356
multi_output = False
@@ -413,6 +416,7 @@ def enet_path(X, y, l1_ratio=0.5, eps=1e-3, n_alphas=100, alphas=None,
413416
model = cd_fast.enet_coordinate_descent_multi_task(
414417
coef_, l1_reg, l2_reg, X, y, max_iter, tol, rng, random)
415418
elif isinstance(precompute, np.ndarray):
419+
precompute = check_array(precompute, 'csc', dtype=np.float64, order='F')
416420
model = cd_fast.enet_coordinate_descent_gram(
417421
coef_, l1_reg, l2_reg, precompute, Xy, y, max_iter,
418422
tol, rng, random, positive)
@@ -1015,7 +1019,7 @@ def fit(self, X, y):
10151019
# Let us not impose fortran ordering or float64 so far: it is
10161020
# not useful for the cross-validation loop and will be done
10171021
# by the model fitting itself
1018-
X = check_array(X, 'csc', copy=False, dtype=np.float64)
1022+
X = check_array(X, 'csc', copy=False)
10191023
if sparse.isspmatrix(X):
10201024
if not np.may_share_memory(reference_to_old_X.data, X.data):
10211025
# X is a sparse matrix and has been copied

sklearn/linear_model/omp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,8 @@ def fit(self, X, y):
805805
self : object
806806
returns an instance of self.
807807
"""
808-
X, y = check_X_y(X, y, dtype=np.float)
808+
X, y = check_X_y(X, y)
809+
X = as_float_array(X, copy=False)
809810
cv = check_cv(self.cv, X, y, classifier=False)
810811
max_iter = (min(max(int(0.1 * X.shape[1]), 5), X.shape[1])
811812
if not self.max_iter

sklearn/manifold/t_sne.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def fit(self, X, y=None):
413413
If the metric is 'precomputed' X must be a square distance
414414
matrix. Otherwise it contains a sample per row.
415415
"""
416-
X = check_array(X, accept_sparse=['csr', 'csc', 'coo'], dtype=np.float)
416+
X = check_array(X, accept_sparse=['csr', 'csc', 'coo'], dtype=np.float64)
417417
random_state = check_random_state(self.random_state)
418418

419419
if self.early_exaggeration < 1.0:

0 commit comments

Comments
 (0)
0