Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be4accf

Browse files
thomasjpfanqinhanmin2014
authored andcommitted
TST refactor test_numeric_stability (#14221)
1 parent 3ab22f9 commit be4accf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sklearn/preprocessing/tests/test_discretization.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ def test_transform_1d_behavior():
135135
assert_raises(ValueError, est.transform, X)
136136

137137

138-
def test_numeric_stability():
138+
@pytest.mark.parametrize('i', range(1, 9))
139+
def test_numeric_stability(i):
139140
X_init = np.array([2., 4., 6., 8., 10.]).reshape(-1, 1)
140141
Xt_expected = np.array([0, 0, 1, 1, 1]).reshape(-1, 1)
141142

142143
# Test up to discretizing nano units
143-
for i in range(1, 9):
144-
X = X_init / 10**i
145-
Xt = KBinsDiscretizer(n_bins=2, encode='ordinal').fit_transform(X)
146-
assert_array_equal(Xt_expected, Xt)
144+
X = X_init / 10**i
145+
Xt = KBinsDiscretizer(n_bins=2, encode='ordinal').fit_transform(X)
146+
assert_array_equal(Xt_expected, Xt)
147147

148148

149149
def test_invalid_encode_option():

0 commit comments

Comments
 (0)