-
Notifications
You must be signed in to change notification settings - Fork 0
/
comparator.py
69 lines (52 loc) · 2.34 KB
/
comparator.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
66
67
68
69
import warnings
import os
import pathlib
warnings.filterwarnings('ignore')
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import glob as gl
plt.rcParams.update({'font.size': 10})
if __name__ == '__main__':
import click
@click.command()
@click.option('-i', '--file', 'file_in', help='Path for getting the data')
@click.option('-m', '--second file', 'rules', help='Path for getting the data')
@click.option('-f', '-- file', 'file', help='Name of the directory')
@click.option('-o', '--out file', 'file_out', help='Name of the file in which data will be stored')
def main(file_in, file_in2, file, file_out):
training = pd.read_csv(file_in, index_col=None)
testing = pd.read_csv(file_in2, index_col=None)
testingErrors = testing.copy()
print('*** Reading Data ***')
paths = str(pathlib.Path().absolute()) + '\\' + file
if not os.path.exists(paths):
os.mkdir(file)
# testId, instanceId, size, isEmpty, peek, peek_obj_type, calledMethod
training.drop(columns=['testId', 'instanceId'], inplace=True)
testing.drop(columns=['testId', 'instanceId'], inplace=True)
# print(training.head(10))
# print(testing.head(10))
# print(testingErrors.head(10))
df = training.eq(testing)
# print(df.head(60))
if len(training) == len(testing):
testingErrors['diff'] = 'No'
for index, row in df.iterrows():
if not row['peek_obj_type']:
testingErrors['diff'][index] = 'Yes'
if not row['isEmpty']:
testingErrors['diff'][index] = 'Yes'
if not row['size']:
testingErrors['diff'][index] = 'Yes'
# if testingErrors['size'][index] == 2:
# testingErrors['errors'][index] = 'Yes'
else:
testingErrors['diff'] = 'Yes'
testingErrors.loc[(testingErrors['size'] != 2) & (testingErrors['isEmpty'] != 'TRUE'), 'diff'] = 'No'
# testingErrors.loc[(testingErrors['size'] < 2) & (testingErrors['isEmpty'] != 'TRUE'), 'diff'] = 'No'
testingErrors.loc[(testingErrors['size'] > 2), 'diff'] = 'Yes'
name = file_out + '.csv'
file_out_aux = paths + '\\'
testingErrors.to_csv(file_out_aux + name)
main()