Passed
Push — master ( 7ebd63...8bd9a3 )
by Simon
06:11
created

EnsembleOptimizer.__init__()   A

Complexity

Conditions 1

Size

Total Lines 26
Code Lines 25

Duplication

Lines 26
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 25
dl 26
loc 26
rs 9.28
c 0
b 0
f 0
cc 1
nop 11

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
from typing import List, Dict, Literal
6
7
from ..search import Search
8
from ..optimizers import EnsembleOptimizer as _EnsembleOptimizer
9
10
11 View Code Duplication
class EnsembleOptimizer(_EnsembleOptimizer, Search):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12
    def __init__(
13
        self,
14
        search_space: Dict[str, list],
15
        initialize: Dict[
16
            Literal["grid", "vertices", "random", "warm_start"], int | List
17
        ] = {"grid": 4, "random": 2, "vertices": 4},
18
        constraints: List[callable] = [],
19
        random_state: int = None,
20
        rand_rest_p: float = 0,
21
        nth_process: int = None,
22
        warm_start_smbo=None,
23
        max_sample_size: int = 10000000,
24
        sampling: Dict[Literal["random"], int] = {"random": 1000000},
25
        replacement: bool = True,
26
    ):
27
        super().__init__(
28
            search_space=search_space,
29
            initialize=initialize,
30
            constraints=constraints,
31
            random_state=random_state,
32
            rand_rest_p=rand_rest_p,
33
            nth_process=nth_process,
34
            warm_start_smbo=warm_start_smbo,
35
            max_sample_size=max_sample_size,
36
            sampling=sampling,
37
            replacement=replacement,
38
        )
39