Passed
Push — master ( 955352...262491 )
by Simon
04:37 queued 13s
created

Constraint.__init__()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
6
def gfo2hyper(search_space, para):
7
    values_dict = {}
8
    for _, key in enumerate(search_space.keys()):
9
        pos_ = int(para[key])
10
        values_dict[key] = search_space[key][pos_]
11
12
    return values_dict
13
14
15
class Constraint:
16
    def __init__(self, constraint, search_space):
17
        self.constraint = constraint
18
        self.search_space = search_space
19
20
    def __call__(self, para):
21
        para = gfo2hyper(self.search_space, para)
22
        return self.constraint(para)
23