Passed
Push — master ( 0c1576...8c2877 )
by Simon
04:40 queued 12s
created

BaseOptimizer._add_result_attributes()   A

Complexity

Conditions 1

Size

Total Lines 21
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 20
nop 10
dl 0
loc 21
rs 9.4
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
class BaseOptimizer:
7
    def __init__(self):
8
        pass
9
10
    def _add_result_attributes(
11
        self,
12
        best_para,
13
        best_score,
14
        best_since_iter,
15
        eval_times,
16
        iter_times,
17
        positions,
18
        search_data,
19
        memory_values_df,
20
        random_seed,
21
    ):
22
        self.best_para = best_para
23
        self.best_score = best_score
24
        self.best_since_iter = best_since_iter
25
        self.eval_times = eval_times
26
        self.iter_times = iter_times
27
        self.positions = positions
28
        self.search_data = search_data
29
        self.memory_values_df = memory_values_df
30
        self.random_seed = random_seed
31