-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmerge.py
65 lines (56 loc) · 1.58 KB
/
merge.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
CRED = '\033[91m'
CEND = '\033[0m'
# Thanks to (https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-python) for the color blog!
import numpy as np
import sys
def shapeCheck(Ax):
'''
:param Ax:
:return:
'''
numberSample = []
eachSample = []
for i in range(len(Ax)):
numberSample.append(Ax[i].shape[0])
eachSample.append(Ax[i].shape[1])
#end-for
return numberSample, eachSample
#end-def
def merge(*args):
'''
:param args:
:return:
'''
args = args[0] ### ignore!
file = args[1] ### ignore!
# print(file)
args = args[2:]
# print(args)
# print(np.load(args[0]).shape)
# print(np.load(args[1]).shape)
Ax = [] # Array --> Ax
for i in args:
Ax.append(np.load(i))
#end-for
numberSample, eachSample = shapeCheck(Ax)
assert len(set(numberSample)) == 1, CRED+'Shape Mismatch! Please choose the same categories features.'+CEND
assert len(set(eachSample)) == 1, CRED+'Shape Mismatch! Please choose the same categories features.'+CEND
T = []
for i in range(len(Ax[0])):
t = []
for i in range(len(Ax)):
t.append(Ax[i][0])
#end-for
t = tuple(t)
T.append(np.concatenate((t), axis=1))
# print('----------------------------')
#end-for
T = np.array(T)
# print(T)
# print(T.shape)
np.save(file='Extracted-Features/{}'.format(file), arr=T)
print('\'{}.npy\' generated; and the new shape: {}.'.format(file, T.shape))
#end-def
###################
merge(sys.argv) ###
###################