10000 Formatting adjusted by black. · scikit-learn/scikit-learn@ed967c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit ed967c7

Browse files
committed
Formatting adjusted by black.
1 parent f81e131 commit ed967c7

File tree

2 files changed

+62
-24
lines changed

2 files changed

+62
-24
lines changed

sklearn/ensemble/_iforest.py

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -486,25 +486,62 @@ def _more_tags(self):
486486
}
487487

488488

489-
_average_path_length_small = np.array((
490-
0.0, 0.0, 1.0,
491-
1.6666666666666666667, 2.1666666666666666667, 2.5666666666666666667,
492-
2.9000000000000000000, 3.1857142857142857143, 3.4357142857142857143,
493-
3.6579365079365079365, 3.8579365079365079365, 4.0397546897546897547,
494-
4.2064213564213564214, 4.3602675102675102675, 4.5031246531246531247,
495-
4.6364579864579864580, 4.7614579864579864580, 4.8791050452815158698,
496-
4.9902161563926269809, 5.0954793142873638230, 5.1954793142873638230,
497-
5.2907174095254590611, 5.3816265004345499702, 5.4685830221736804049,
498-
5.5519163555070137383, 5.6319163555070137383, 5.7088394324300906613,
499-
5.7829135065041647354, 5.8543420779327361640, 5.9233075951741154743,
500-
5.9899742618407821410, 6.0544903908730402055, 6.1169903908730402055,
501-
6.1775964514791008116, 6.2364199808908655175, 6.2935628380337226603,
502-
6.3491183935892782159, 6.4031724476433322699, 6.4558040265907006910,
503-
6.5070860778727519730, 6.5570860778727519730, 6.6058665656776300218,
504-
6.6534856132966776409, 6.6999972412036543850, 6.7454517866581998396,
505-
6.7898962311026442840, 6.8333744919722095014, 6.8759276834615712036,
506-
6.9175943501282378702, 6.9584106766588501151, 6.9984106766588501151,
507-
7.0376263629333599190))
489+
_average_path_length_small = np.array(
490+
(
491+
0.0,
492+
0.0,
493+
1.0,
494+
1.6666666666666666667,
495+
2.1666666666666666667,
496+
2.5666666666666666667,
497+
2.9000000000000000000,
498+
3.1857142857142857143,
499+
3.4357142857142857143,
500+
3.6579365079365079365,
501+
3.8579365079365079365,
502+
4.0397546897546897547,
503+
4.2064213564213564214,
504+
4.3602675102675102675,
505+
4.5031246531246531247,
506+
4.6364579864579864580,
507+
4.7614579864579864580,
508+
4.8791050452815158698,
509+
4.9902161563926269809,
510+
5.0954793142873638230,
511+
5.1954793142873638230,
512+
5.2907174095254590611,
513+
5.3816265004345499702,
514+
5.4685830221736804049,
515+
5.5519163555070137383,
516+
5.6319163555070137383,
517+
5.7088394324300906613,
518+
5.7829135065041647354,
519+
5.8543420779327361640,
520+
5.9233075951741154743,
521+
5.9899742618407821410,
522+
6.0544903908730402055,
523+
6.1169903908730402055,
524+
6.1775964514791008116,
525+
6.2364199808908655175,
526+
6.2935628380337226603,
527+
6.3491183935892782159,
528+
6.4031724476433322699,
529+
6.4558040265907006910,
530+
6.5070860778727519730,
531+
6.5570860778727519730,
532+
6.6058665656776300218,
533+
6.6534856132966776409,
534+
6.6999972412036543850,
535+
6.7454517866581998396,
536+
6.7898962311026442840,
537+
6.8333744919722095014,
538+
6.8759276834615712036,
539+
6.9175943501282378702,
540+
6.9584106766588501151,
541+
6.9984106766588501151,
542+
7.0376263629333599190,
543+
)
544+
)
508545

509546

510547
def _average_path_length(n_samples_leaf):
@@ -533,7 +570,8 @@ def _average_path_length(n_samples_leaf):
533570
not_mask = ~mask_small
534571

535572
average_path_length[mask_small] = _average_path_length_small[
536-
n_samples_leaf[mask_small]]
573+
n_samples_leaf[mask_small]
574+
]
537575

538576
# Average path length equals 2*(H(n)-1), with H(n) the nth harmonic number.
539577
# For the harmonic number calculation,
@@ -546,11 +584,11 @@ def _average_path_length(n_samples_leaf):
546584
# Wang, W. Harmonic Number Expansions of the Ramanujan Type.
547585
# Results Math 73, 161 (2018). https://doi.org/10.1007/s00025-018-0920-8
548586

549-
tmp = 1.0/np.square(n_samples_leaf[not_mask])
587+
tmp = 1.0 / np.square(n_samples_leaf[not_mask])
550588
average_path_length[not_mask] = (
551589
2.0 * (np.log(n_samples_leaf[not_mask]) - 1.0 + np.euler_gamma)
552-
+ 1.0/n_samples_leaf[not_mask]
553-
- tmp*(1.0/6.0 - tmp*(1.0/60.0 - tmp/126.0))
590+
+ 1.0 / n_samples_leaf[not_mask]
591+
- tmp * (1.0 / 6.0 - tmp * (1.0 / 60.0 - tmp / 126.0))
554592
)
555593

556594
return average_path_length.reshape(n_samples_leaf_shape)

sklearn/ensemble/tests/test_iforest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def test_iforest_average_path_length():
230230
# It tests non-regression for #8549 which used the wrong formula
231231
# for average path length, strictly for the integer case
232232
# Updated to check average path length when input is <= 2 (issue #11839)
233-
result_5 = 77.0/30.0
233+
result_5 = 77.0 / 30.0
234234
result_999 = 12.9689417211006898253130364
235235
assert_allclose(_average_path_length([0]), [0.0])
236236
assert_allclose(_average_path_length([1]), [0.0])

0 commit comments

Comments
 (0)
0