Passed
Push — master ( 08aa78...571090 )
by Simon
02:09 queued 12s
created

hyperactive.process._process_()   A

Complexity

Conditions 2

Size

Total Lines 41
Code Lines 36

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 36
nop 12
dl 0
loc 41
rs 9.016
c 0
b 0
f 0

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
6
def _process_(
7
    nth_process,
8
    objective_function,
9
    search_space,
10
    optimizer,
11
    n_iter,
12
    memory,
13
    memory_warm_start,
14
    max_time,
15
    max_score,
16
    random_state,
17
    verbosity,
18
    **kwargs
19
):
20
    if "progress_bar" in verbosity:
21
        verbosity_gfo = ["progress_bar"]
22
    else:
23
        verbosity_gfo = []
24
25
    optimizer.search(
26
        objective_function=objective_function,
27
        n_iter=n_iter,
28
        max_time=max_time,
29
        max_score=max_score,
30
        memory=memory,
31
        memory_warm_start=memory_warm_start,
32
        verbosity=verbosity_gfo,
33
        random_state=random_state,
34
        nth_process=nth_process,
35
    )
36
37
    return {
38
        "nth_process": nth_process,
39
        "best_para": optimizer.best_para,
40
        "best_score": optimizer.best_score,
41
        "best_iter": optimizer.p_bar._best_since_iter,
42
        "eval_times": optimizer.eval_time,
43
        "iter_times": optimizer.iter_time,
44
        "positions": optimizer.positions,
45
        "results": optimizer.results,
46
        "memory_values_df": optimizer.memory_values_df,
47
    }
48