OptimizerAttributes._add_result_attributes()   A
last analyzed

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
"""optimizer_attributes module for Hyperactive optimization."""
2
3
# Email: [email protected]
4
# License: MIT License
5
6
7
class OptimizerAttributes:
8
    """OptimizerAttributes class."""
9
10
    def __init__(self):
11
        self.best_para = None
12
        self.best_score = None
13
        self.best_since_iter = None
14
        self.eval_times = None
15
        self.iter_times = None
16
        self.search_data = None
17
        self.random_seed = None
18
19
    def _add_result_attributes(
20
        self,
21
        best_para,
22
        best_score,
23
        best_since_iter,
24
        eval_times,
25
        iter_times,
26
        search_data,
27
        random_seed,
28
    ):
29
        self.best_para = best_para
30
        self.best_score = best_score
31
        self.best_since_iter = best_since_iter
32
        self.eval_times = eval_times
33
        self.iter_times = iter_times
34
        self.search_data = search_data
35
        self.random_seed = random_seed
36