Skip to content

Commit f68108a

Browse files
committed
Improve cfpq_eval result rendering
1 parent ed81b85 commit f68108a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

cfpq_eval/eval_all_pairs_cflr.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from cfpq_eval.runners.all_pairs_cflr_tool_runner import IncompatibleCflrToolError
1414
from cfpq_eval.runners.all_pairs_cflr_tool_runner_facade import run_appropriate_all_pairs_cflr_tool
1515

16-
DISPLAY_STD_THRESHOLD = 0.1
16+
DISPLAY_STD_THRESHOLD = 0.01
1717

1818
# see `man timeout`
1919
TIMEOUT_EXIT_CODE = 124
@@ -94,9 +94,10 @@ def run_experiment(
9494

9595

9696
def round_to_significant_digits(x: float, digits: int = 2) -> float:
97-
if x == 0:
98-
return x
99-
return round(x, max(0, -int(floor(log10(abs(x)))) + digits - 1))
97+
if x == 0.0:
98+
return 0.0
99+
absolute_digits = -int(floor(log10(abs(x)))) + digits - 1
100+
return round(x, absolute_digits) if absolute_digits > 0 else int(round(x))
100101

101102

102103
def reduce_result_file_to_one_row(result_file_path: Path) -> pd.DataFrame:
@@ -136,14 +137,14 @@ def reduce_result_file_to_one_row(result_file_path: Path) -> pd.DataFrame:
136137
round_to_significant_digits(ram_gb_mean)
137138
if ram_gb_std < DISPLAY_STD_THRESHOLD * ram_gb_mean
138139
else f"{round_to_significant_digits(ram_gb_mean)}"
139-
f" ± {round_to_significant_digits(ram_gb_std)}"
140+
f" ± {int(ram_gb_std / ram_gb_mean * 100)}%"
140141
],
141142
'time_sec': [
142143
# Graspan reports analysis time in whole seconds, so it may report 0
143144
(round_to_significant_digits(time_sec_mean) if time_sec_mean != 0 else "< 1")
144145
if time_sec_std < DISPLAY_STD_THRESHOLD * time_sec_mean
145146
else f"{round_to_significant_digits(time_sec_mean)}"
146-
f" ± {round_to_significant_digits(time_sec_std)}"
147+
f" ± {int(time_sec_std / time_sec_mean * 100)}%"
147148
]
148149
})
149150
return df
@@ -172,6 +173,14 @@ def display_results_for_grammar(df: pd.DataFrame, grammar: str):
172173
key=lambda graph: min_numeric(df[df['graph'] == graph]['time_sec'])
173174
))
174175

176+
duplicates = df[df.duplicated(subset=['graph', 'algo'], keep=False)]
177+
if not duplicates.empty:
178+
warnings.warn(
179+
"Duplicate entries found. Repeated entries will be ignored:\n"
180+
f"{str(duplicates)}"
181+
)
182+
df = df.drop_duplicates(subset=['graph', 'algo'])
183+
175184
s_edges_df = df.pivot(index='graph', columns='algo', values='s_edges').sort_index()
176185
s_edges_df.columns = [
177186
f'{col} (HAS KNOWN BUGS)'

0 commit comments

Comments
 (0)