Passed
Push — master ( 9ff666...1a4396 )
by Simon
03:24
created

hyperactive.util.util.init_candidate()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nop 3
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
6
import numpy as np
7
8
9
def init_candidate(_main_args_, nth_process, Candidate):
10
    _main_args_._set_random_seed(nth_process)
11
    _cand_ = Candidate(nth_process, _main_args_)
12
13
    return _cand_
14
15
16
def merge_dicts(base_dict, added_dict):
17
    # overwrite default values
18
    for key in base_dict.keys():
19
        if key in list(added_dict.keys()):
20
            base_dict[key] = added_dict[key]
21
22
    return base_dict
23
24
25
def sort_for_best(sort, sort_by):
26
    # Returns two lists sorted by the second
27
    sort = np.array(sort)
28
    sort_by = np.array(sort_by)
29
30
    index_best = list(sort_by.argsort()[::-1])
31
32
    sort_sorted = sort[index_best]
33
    sort_by_sorted = sort_by[index_best]
34
35
    return sort_sorted, sort_by_sorted
36