Passed
Push — master ( a45661...26ba2e )
by Simon
01:37
created

hyperactive.util.util.merge_dicts()   A

Complexity

Conditions 3

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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