Skip to content

Commit

Permalink
Added comments to localize where readonly mode is broken
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurmensch committed Jun 25, 2015
1 parent df93b5a commit a6894e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions sklearn/utils/estimator_checks.py
Expand Up @@ -397,9 +397,10 @@ def check_dtype_object(name, Estimator):
def check_transformer_general(name, Transformer, readonly=False):
X, y = _make_blobs_with_mode(n_samples=30, centers=[[0, 0, 0], [1, 1, 1]],
random_state=0, n_features=2, cluster_std=0.1,
readonly=readonly)
X = StandardScaler().fit_transform(X)
X -= X.min()
positive=True, readonly=readonly)
# TODO: removed ScandardScaler as this breaks readonly mode
# X = StandardScaler().fit_transform(X)
# X -= X.min()
_check_transformer(name, Transformer, X, y)
_check_transformer(name, Transformer, X.tolist(), y.tolist())

Expand Down Expand Up @@ -708,6 +709,7 @@ def check_estimators_partial_fit_n_features(name, Alg):

def check_clustering(name, Alg, readonly=False):
X, y = _make_blobs_with_mode(n_samples=50, random_state=1, readonly=readonly)
# TODO: this breaks read only mode
X, y = shuffle(X, y, random_state=7)
X = StandardScaler().fit_transform(X)
n_samples, n_features = X.shape
Expand Down Expand Up @@ -1038,7 +1040,7 @@ def check_regressors_int(name, Regressor):


def check_regressors_train_readonly(name, Regressors):
check_regressors_train(name, Regressors, readonly=False)
check_regressors_train(name, Regressors, readonly=True)


def check_regressors_train(name, Regressor, readonly=False):
Expand Down
6 changes: 4 additions & 2 deletions sklearn/utils/validation.py
Expand Up @@ -363,8 +363,10 @@ def check_array(array, accept_sparse=None, dtype="numeric", order=None,
else:
if ensure_2d:
array = np.atleast_2d(array)

array = np.array(array, dtype=dtype, order=order, copy=copy)
if not copy:
array = np.asarray(array, dtype=dtype, order=order)
else:
array = np.array(array, dtype=dtype, order=order, copy=copy)
# make sure we actually converted to numeric:
if dtype_numeric and array.dtype.kind == "O":
array = array.astype(np.float64)
Expand Down

0 comments on commit a6894e4

Please sign in to comment.