Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoix committed Feb 26, 2019
1 parent cefa81b commit 0a1bcf5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion sklearn/ensemble/iforest.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,10 @@ def score_samples(self, X):

scores = 2 ** (
-depths
/ (len(self.estimators_) * _average_path_length([self.max_samples_]))
/ (
len(self.estimators_)
* _average_path_length([self.max_samples_])
)
)

# Take the opposite of the scores as bigger is better (here less
Expand Down
16 changes: 11 additions & 5 deletions sklearn/ensemble/tests/test_iforest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import numpy as np

from sklearn.utils.testing import assert_almost_equal
from sklearn.utils.testing import assert_array_equal
from sklearn.utils.testing import assert_array_almost_equal
from sklearn.utils.testing import assert_raises
Expand Down Expand Up @@ -268,10 +267,17 @@ def test_iforest_average_path_length():
result_two = 2. * (np.log(998.) + np.euler_gamma) - 2. * 998. / 999.

assert_array_almost_equal(_average_path_length([1]), [1.], decimal=10)
assert_array_almost_equal(_average_path_length([5]), [result_one], decimal=10)
assert_array_almost_equal(_average_path_length([999]), [result_two], decimal=10)
assert_array_almost_equal(_average_path_length(np.array([1, 5, 999])),
[1., result_one, result_two], decimal=10)
assert_array_almost_equal(
_average_path_length([5]), [result_one], decimal=10
)
assert_array_almost_equal(
_average_path_length([999]), [result_two], decimal=10
)
assert_array_almost_equal(
_average_path_length(np.array([1, 5, 999])),
[1.0, result_one, result_two],
decimal=10,
)


@pytest.mark.filterwarnings('ignore:default contamination')
Expand Down

0 comments on commit 0a1bcf5

Please sign in to comment.