-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmerge_dicts.py
31 lines (23 loc) · 1021 Bytes
/
merge_dicts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os, re, sys
import numpy as np
import pandas as pd
def merge_dicts(*dict_args):
result = {}
for item in dict_args:
result.update(item)
return result
def merge_background_scores(filepath, identifier):
all_dict_background = []
for n in range(5):
dict_background = np.load(filepath + 'dict_%s_background_%s.npy' % (identifier, str(n)), allow_pickle=True).item()
all_dict_background.append(dict_background)
all_dict_background1 = merge_dicts(*all_dict_background)
return all_dict_background1
def merge_background_scores_K(filepath, identifier):
num = 9 if identifier == '100K' else 43
all_dict_background = []
for n in range(num):
dict_background = np.load(filepath + 'dict_score_background_%s_%s.npy' % (identifier, str(n)), allow_pickle=True).item()
all_dict_background.append(dict_background)
all_dict_background1 = merge_dicts(*all_dict_background)
return all_dict_background1