@@ -327,32 +327,33 @@ def test_iforest_deprecation():
327
327
def test_iforest_with_uniform_data ():
328
328
"""Test whether iforest predicts inliers when using uniform data"""
329
329
330
- # 2-d array of all 1s
331
- X = np .ones ((100 , 10 ))
332
- iforest = IsolationForest ()
333
- iforest .fit (X )
334
-
335
- rng = np .random .RandomState (0 )
336
-
337
- assert all (iforest .predict (X ) == 1 )
338
- assert all (iforest .predict (rng .randn (100 , 10 )) == 1 )
339
- assert all (iforest .predict (X + 1 ) == 1 )
340
- assert all (iforest .predict (X - 1 ) == 1 )
341
-
342
- # 2-d array where columns contain the same value across rows
343
- X = np .repeat (rng .randn (1 , 10 ), 100 , 0 )
344
- iforest = IsolationForest ()
345
- iforest .fit (X )
346
-
347
- assert all (iforest .predict (X ) == 1 )
348
- assert all (iforest .predict (rng .randn (100 , 10 )) == 1 )
349
- assert all (iforest .predict (np .ones ((100 , 10 ))) == 1 )
350
-
351
- # Single row
352
- X = rng .randn (1 , 10 )
353
- iforest = IsolationForest ()
354
- iforest .fit (X )
355
-
356
- assert all (iforest .predict (X ) == 1 )
357
- assert all (iforest .predict (rng .randn (100 , 10 )) == 1 )
358
- assert all (iforest .predict (np .ones ((100 , 10 ))) == 1 )
330
+ for n_samples , n_features in np .random .randint (10 , 200 , size = (10 , 2 )):
331
+ # 2-d array of all 1s
332
+ X = np .ones ((n_samples , n_features ))
333
+ iforest = IsolationForest ()
334
+ iforest .fit (X )
335
+
336
+ rng = np .random .RandomState (0 )
337
+
338
+ assert all (iforest .predict (X ) == 1 )
339
+ assert all (iforest .predict (rng .randn (n_samples , n_features )) == 1 )
340
+ assert all (iforest .predict (X + 1 ) == 1 )
341
+ assert all (iforest .predict (X - 1 ) == 1 )
342
+
343
+ # 2-d array where columns contain the same value across rows
344
+ X = np .repeat (rng .randn (1 , n_features ), n_samples , 0 )
345
+ iforest = IsolationForest ()
346
+ iforest .fit (X )
347
+
348
+ assert all (iforest .predict (X ) == 1 )
349
+ assert all (iforest .predict (rng .randn (n_samples , n_features )) == 1 )
350
+ assert all (iforest .predict (np .ones ((n_samples , n_features ))) == 1 )
351
+
352
+ # Single row
353
+ X = rng .randn (1 , n_features )
354
+ iforest = IsolationForest ()
355
+ iforest .fit (X )
356
+
357
+ assert all (iforest .predict (X ) == 1 )
358
+ assert all (iforest .predict (rng .randn (n_samples , n_features )) == 1 )
359
+ assert all (iforest .predict (np .ones ((n_samples , n_features ))) == 1 )
0 commit comments