Passed
Push — master ( 193da7...4bb259 )
by Simon
01:36 queued 11s
created

hyperactive.search_process.search_process_shortMem   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 62
Duplicated Lines 61.29 %

Importance

Changes 0
Metric Value
eloc 47
dl 38
loc 62
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A SearchProcessShortMem.__init__() 38 38 1
A SearchProcessShortMem._memory2dataframe() 0 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
6
import numpy as np
7
import pandas as pd
8
9
from ..candidate import CandidateShortMem
10
from .search_process_base import SearchProcess
11
12
13
class SearchProcessShortMem(SearchProcess):
14 View Code Duplication
    def __init__(
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
15
        self,
16
        nth_process,
17
        verb,
18
        objective_function,
19
        search_space,
20
        n_iter,
21
        function_parameter,
22
        optimizer,
23
        n_jobs,
24
        init_para,
25
        memory,
26
        hyperactive,
27
        random_state,
28
    ):
29
        super().__init__(
30
            nth_process,
31
            verb,
32
            objective_function,
33
            search_space,
34
            n_iter,
35
            function_parameter,
36
            optimizer,
37
            n_jobs,
38
            init_para,
39
            memory,
40
            hyperactive,
41
            random_state,
42
        )
43
44
        self.cand = CandidateShortMem(
45
            self.objective_function,
46
            self.function_parameter,
47
            self.search_space,
48
            self.init_para,
49
            self.memory,
50
            verb,
51
            hyperactive,
52
        )
53
54
    def _memory2dataframe(self, memory):
55
        positions = np.array(list(memory.keys()))
56
        scores_list = list(memory.values())
57
58
        positions_df = pd.DataFrame(positions, columns=list(self.search_space.keys()))
59
        scores_df = pd.DataFrame(scores_list)
60
61
        self.position_results = pd.concat([positions_df, scores_df], axis=1)
62
63