Passed
Pull Request — master (#101)
by Simon
01:48
created

hyperactive.base.search_space._properties   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 4

4 Functions

Rating   Name   Duplication   Size   Complexity  
A position_space() 0 4 1
A n_dim() 0 2 1
A dim_names() 0 2 1
A calculate_properties() 0 10 1
1
import numpy as np
2
3
4
def n_dim(search_space):
5
    return len(search_space)
6
7
8
def dim_names(search_space):
9
    return list(search_space.keys())
10
11
12
def position_space(search_space):
13
    return {
14
        key: np.array(range(len(search_space[key])))
15
        for key in search_space.keys()
16
    }
17
18
19
def calculate_properties(func):
20
    def wrapper(self, *args, **kwargs):
21
        func(self, *args, **kwargs)
22
23
        self.n_dim = n_dim(self._search_space)
24
        self.dim_names = dim_names(self._search_space)
25
        self.position_space = position_space(self._search_space)
26
        print(" ---> search-space updated!")
27
28
    return wrapper
29