-
Notifications
You must be signed in to change notification settings - Fork 9
/
test.py
47 lines (39 loc) · 1.5 KB
/
test.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
# Gery Casiez
# August 2023
import os
import math
import sys
import pandas
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('implementation')
parser.add_argument('filename')
args = parser.parse_args()
if not(os.path.isfile(args.filename)):
print("%s does not exist"%args.filename, file=sys.stderr)
sys.exit()
df = pandas.read_csv('../groundTruth.csv')
df2 = pandas.read_csv(args.filename)
problem = False
if df.shape[0] != df2.shape[0]:
print("The test file does not have the correct number of lines.", file=sys.stderr)
sys.exit()
for (index, row), (index2, row2) in zip(df.iterrows(), df2.iterrows()):
if math.fabs(row['timestamp'] - row2['timestamp']) > 0.0001:
print("Timestamps are different : %s != %s"%(row['timestamp'], row2['timestamp']), file=sys.stderr)
problem = True
break
if math.fabs(row['noisy'] - row2['noisy']) > 0.0001:
print("noisy data is different: %s != %s"%(row['noisy'], row2['noisy']), file=sys.stderr)
problem = True
break
if math.fabs(row['filtered'] - row2['filtered']) > 0.0001:
print("The filtered value differs from the ground truth: %s != %s"%(row['filtered'], row2['filtered']), file=sys.stderr)
print("Check your parameters or your implementation")
problem = True
break
if problem:
print("::error Problem with %s checking"%args.implementation, file=sys.stderr)
sys.exit(1)
else:
print("\n>>>>>> %s implementation looks good. <<<<<<\n"%args.implementation)