Skip to content

Commit 42f3b84

Browse files
authored
Jesse (gousiosg#26)
* Updated precision * Updated rounding and column format * Update rq1 * restore deleted files * Add rq1 table generation script
1 parent 4101af0 commit 42f3b84

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

rq1_data.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
import pandas as pd
22
from common import shortNames
33

4-
CALC_NAMES = ['FP', 'FN', 'TP']
4+
FIELD_N = 'N'
5+
FIELD_PROPERTY = 'Property'
6+
FIELD_JACOCO = '\\jacoco'
7+
FIELD_SYSNAME = '\\sysname'
8+
FIELD_REACHABLE = 'Reachable'
9+
FIELD_IMPOSSIBLE = 'Impossible'
10+
FIELD_MISSED = 'Missed'
11+
12+
PROP_NAMES = [FIELD_N, FIELD_PROPERTY]
13+
CALC_NAMES = [FIELD_JACOCO, FIELD_IMPOSSIBLE, FIELD_MISSED, FIELD_SYSNAME]
14+
TABLE_HEADER = PROP_NAMES + CALC_NAMES
515

616
projects = [
717
('convex', 'artifacts/experiment/rq1_convex.csv', 'artifacts/experiment/rq1_table_convex.tex'),
@@ -51,13 +61,17 @@
5161
data['TN'] = data['TN'].apply(lambda v: 1 if v else 0)
5262

5363
# add Name as a friendly name for each entrypoint
54-
data['Property'] = data['entryPoint'].apply(lambda v: shortNames[v])
55-
56-
df = data[['Property', 'FP', 'FN', 'TP']].groupby(by='Property').sum().round(2)
57-
df['+Ratio'] = df['FP'] / df['TP']
58-
df['N'] = pd.RangeIndex(start=rowCount, stop=len(df.index) + rowCount)
64+
data[FIELD_PROPERTY] = data['entryPoint'].apply(lambda v: shortNames[v])
65+
66+
df = data[[FIELD_PROPERTY, 'FP', 'FN', 'TP']].groupby(by=FIELD_PROPERTY).sum().round(2)
67+
df[FIELD_JACOCO] = df['FP'] + df['TP']
68+
df[FIELD_REACHABLE] = df['TP']
69+
df[FIELD_IMPOSSIBLE] = df['FP']
70+
df[FIELD_MISSED] = df['FN']
71+
df[FIELD_SYSNAME] = df['FN'] + df['TP']
72+
df[FIELD_N] = pd.RangeIndex(start=rowCount, stop=len(df.index) + rowCount)
5973
df.reset_index(inplace=True)
60-
dfSubset = df[['N', 'Property', 'FP', 'FN', 'TP', '+Ratio']]
74+
dfSubset = df[TABLE_HEADER]
6175

6276
rowCount = len(df.index) + rowCount
6377
dataSetSum[projName] = dfSubset.copy()
@@ -89,30 +103,34 @@
89103

90104
projMean = dataSetSum[projName][CALC_NAMES].mean().round()
91105
projMean['_style'] = 'BOLD'
92-
projMean['N'] = ''
93-
projMean['Property'] = 'Average'
94-
projMean['+Ratio'] = projMean['FP'] / projMean['TP']
106+
projMean[FIELD_N] = ''
107+
projMean[FIELD_PROPERTY] = 'Average'
95108
dataSetSum[projName].loc['mean'] = projMean
96109

97-
header = dict(zip(['N', 'Property', 'FP', 'FN', 'TP', '+Ratio'], ['', '', '', '', '', '']))
110+
header = dict(zip(TABLE_HEADER, map(lambda v: '', TABLE_HEADER)))
98111

99112
newDF = pd.concat([
100113
newDF,
101-
pd.DataFrame(header | {'_style': 'HEADER', 'Property': projName}, index=[0]), # project header
114+
pd.DataFrame(header | {'_style': 'HEADER', FIELD_PROPERTY: projName}, index=[0]), # project header
102115
dataSetSum[projName] # project data / avg
103116
], ignore_index=True)
104117

105118
bold_rows = newDF[ newDF['_style'] == 'BOLD' ].index
106119
header_rows = newDF[ newDF['_style'] == 'HEADER' ].index
120+
data_rows = newDF[ newDF['_style'] != 'HEADER' ].index
107121

108122
latexTable = newDF \
109123
.drop(columns=['_style']) \
110124
.style \
111125
.hide(axis=0) \
112-
.format(precision=0) \
126+
.format({
127+
FIELD_JACOCO: "{:.0f}",
128+
FIELD_IMPOSSIBLE: "-{:.0f}",
129+
FIELD_MISSED: "+{:.0f}",
130+
FIELD_SYSNAME: "{:.0f}"
131+
}, subset=pd.IndexSlice[data_rows, :]) \
113132
.set_properties(subset=pd.IndexSlice[header_rows, :], **{'HEADER': ''}) \
114133
.set_properties(subset=pd.IndexSlice[bold_rows, :], **{'textbf': '--rwrap'}) \
115-
.format(subset=pd.IndexSlice['+Ratio'], precision=2) \
116134
.to_latex(hrules=False, column_format="llrrrr")
117135

118136
outTable = ''

0 commit comments

Comments
 (0)