Skip to content

Commit 3c46eba

Browse files
committed
COSMIT pep8, removing unused imports and recommend toarray instead of todense
1 parent f49773d commit 3c46eba

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

sklearn/feature_extraction/tests/test_feature_hasher.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import numpy as np
2-
import scipy.sparse as sp
32

43
from sklearn.feature_extraction import FeatureHasher
54

65
from nose.tools import assert_raises, assert_true
76
from numpy.testing import assert_array_equal, assert_equal
8-
from sklearn.utils.testing import assert_in
97

108

119
def test_feature_hasher_dicts():
@@ -68,7 +66,7 @@ def test_hasher_invalid_input():
6866
assert_raises(ValueError, FeatureHasher, n_features=0)
6967
assert_raises(TypeError, FeatureHasher, n_features='ham')
7068

71-
h = FeatureHasher(n_features=np.uint16(2**6))
69+
h = FeatureHasher(n_features=np.uint16(2 ** 6))
7270
assert_raises(ValueError, h.transform, [])
7371
assert_raises(Exception, h.transform, [[5.5]])
7472
assert_raises(Exception, h.transform, [[None]])

sklearn/utils/validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def array2d(X, dtype=None, order=None, copy=False):
6969
"""Returns at least 2-d array with data from X"""
7070
if sparse.issparse(X):
7171
raise TypeError('A sparse matrix was passed, but dense data '
72-
'is required. Use X.todense() to convert to dense.')
72+
'is required. Use X.toarray() to convert to dense.')
7373
X_2d = np.asarray(np.atleast_2d(X), dtype=dtype, order=order)
7474
assert_all_finite(X_2d)
7575
if X is X_2d and copy:
@@ -78,7 +78,7 @@ def array2d(X, dtype=None, order=None, copy=False):
7878

7979

8080
def atleast2d_or_csc(X, dtype=None, order=None, copy=False):
81-
"""Like numpy.atleast_2d, but converts sparse matrices to CSC format
81+
"""Like numpy.atleast_2d, but converts sparse matrices to CSC format.
8282
8383
Also, converts np.matrix to np.ndarray.
8484
"""

0 commit comments

Comments
 (0)