Skip to content

Commit 5358be5

Browse files
committed
TST crank up preprocessing tests to 99% coverage
Fixes scikit-learn#3347. (nosetests reports no missing lines, so 99% seems to be a roundoff error, or a hint that 100% coverage is impossible :p)
1 parent c176ced commit 5358be5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sklearn/preprocessing/tests/test_data.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def test_polynomial_features():
6565
X_poly = interact.fit_transform(X)
6666
assert_array_almost_equal(X_poly, P2[:, [0, 1, 2, 4]])
6767

68+
assert_raises(ValueError, interact.transform, X[:, 1:])
69+
6870

6971
def test_scaler_1d():
7072
"""Test scaling of dataset along single axis"""
@@ -92,6 +94,9 @@ def test_scaler_1d():
9294
assert_array_almost_equal(X_scaled.mean(axis=0), 0.0)
9395
assert_array_almost_equal(X_scaled.std(axis=0), 1.0)
9496

97+
X = np.ones(5)
98+
assert_array_equal(scale(X, with_mean=False), X)
99+
95100

96101
def test_scaler_2d_arrays():
97102
"""Test scaling of 2d array along first axis"""
@@ -511,8 +516,12 @@ def test_normalizer_l2():
511516
assert_almost_equal(la.norm(X_norm[3]), 0.0)
512517

513518

514-
def test_normalize_errors():
515-
"""Check that invalid arguments yield ValueError"""
519+
def test_normalize():
520+
"""Test normalize function"""
521+
# Only tests functionality not used by the tests for Normalizer.
522+
X = np.random.RandomState(37).randn(3, 2)
523+
assert_array_equal(normalize(X, copy=False),
524+
normalize(X.T, axis=0, copy=False).T)
516525
assert_raises(ValueError, normalize, [[0]], axis=2)
517526
assert_raises(ValueError, normalize, [[0]], norm='l3')
518527

0 commit comments

Comments
 (0)