Passed
Push — master ( 199200...2b2f7b )
by Simon
04:29
created

OptimizerAttributes._add_result_attributes()   A

Complexity

Conditions 1

Size

Total Lines 17
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

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