-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTests.py
58 lines (51 loc) · 2.34 KB
/
Tests.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
def test_ids_match():
events = np.arange(0,512,1)
dimensions = ((16,32),(12,32))
j = 0
for shape in dimensions:
ids_tensor = get_ids_tensor(shape,0)
df_tensor_idx = df_id.applymap(lambda x:get_tensor_idx(x,shape,0),na_action="ignore")
# qdc_tensor = df_QDC.apply(lambda x: get_tensor_filled(x,(12,32,2)),axis=1)
for pos in events:
test_array=df_tensor_idx.loc[pos]
n_entries = len(test_array[~test_array.isnull()])
for i,v in enumerate(test_array):
try:
x = int(v[0])
z = int(v[1])
y = int(v[2])
if ids_tensor[x,z,y] == df_id.loc[pos,i] and i == n_entries - 1:
print(ids_tensor[x,z,y] ,df_id.loc[pos,i])
j += 1
except:
pass
print(f"################## j is equal to {j} for dim {shape} #################")
j = 0
def test_qdc_match():
events = np.arange(0,512,1)
dimensions = ((16,32),(12,32))
j = 0
for shape in dimensions:
ids_tensor = get_ids_tensor(shape,0)
df_tensor_idx = df_id.applymap(lambda x:get_tensor_idx(x,shape,0),na_action="ignore")
shape_full = shape + (2,)
print(shape_full)
qdc_tensor = df_QDC.apply(lambda x: get_tensor_filled(x,shape_full,df_tensor_idx),axis=1)
for pos in events:
test_array=df_tensor_idx.loc[pos]
n_entries = len(test_array[~test_array.isnull()])
for i,v in enumerate(test_array):
try:
x = int(v[0])
z = int(v[1])
y = int(v[2])
#print(qdc_tensor.loc[pos][x,z,y], df_QDC.loc[pos,i] )
if qdc_tensor.loc[pos][x,z,y] == df_QDC.loc[pos,i] and i == n_entries - 1:
j += 1
except:
pass
print(f"################## j is equal to {j} for dim {shape} #################")
j = 0
# except:
# return f"Error in columns {i} of event {pos}"
test_qdc_match()