Total Complexity | 4 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 0 |
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 |