8000 Adding test for issue #4297, isotonic infinite loop · mjbommar/scikit-learn@da04cd9 · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit da04cd9

Browse files
committed
Adding test for issue scikit-learn#4297, isotonic infinite loop
1 parent 13a4ffb commit da04cd9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

sklearn/tests/test_isotonic.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,25 @@ def test_isotonic_duplicate_min_entry():
308308
all_predictions_finite = np.all(np.isfinite(ir.predict(x)))
309309
assert_true(all_predictions_finite)
310310

311+
312+
def test_isotonic_zero_weight_loop():
313+
# Test from @ogrisel's issue:
314+
# https://github.com/scikit-learn/scikit-learn/issues/4297
315+
316+
regression = IsotonicRegression()
317+
n_samples = 50
318+
x = np.linspace(-3, 3, n_samples)
319+
y = x + np.random.uniform(size=n_samples)
320+
321+
# Get some random weights and zero out
322+
w = np.random.uniform(size=n_samples)
323+
w[5:8] = 0
324+
regression.fit(x, y, sample_weight=w)
325+
326+
# This will hang in failure case.
327+
regression.fit(x, y, sample_weight=w)
328+
329+
311330
if __name__ == "__main__":
312331
import nose
313332
nose.run(argv=['', __file__])

0 commit comments

Comments
 (0)
0