File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,25 @@ def test_isotonic_duplicate_min_entry():
308
308
all_predictions_finite = np .all (np .isfinite (ir .predict (x )))
309
309
assert_true (all_predictions_finite )
310
310
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
+
311
330
if __name__ == "__main__" :
312
331
import nose
313
332
nose .run (argv = ['' , __file__ ])
You can’t perform that action at this time.
0 commit comments