Skip to content

Commit 7a2d326

Browse files
committed
Improve cfpq_eval output messages
1 parent 2c36b27 commit 7a2d326

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cfpq_eval/eval_all_pairs_cflr.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def run_experiment(
5656
if os.path.exists(rewritten_grammar_path):
5757
grammar_path = rewritten_grammar_path
5858

59+
if is_enough_data_collected(result_file_path, rounds):
60+
print(f" Enough data has already been saved to {result_file_path}")
61+
return
62+
5963
for _ in range(rounds):
6064
if is_enough_data_collected(result_file_path, rounds):
6165
return
@@ -187,6 +191,12 @@ def min_numeric(series: pd.Series) -> float:
187191
numeric_series = pd.to_numeric(series, errors='coerce').dropna()
188192
return float('inf') if numeric_series.empty else numeric_series.min()
189193

194+
def format_int(x):
195+
try:
196+
return format(x, ',').replace(',', '\\,')
197+
except ValueError:
198+
return x
199+
190200

191201
def display_results_for_grammar(df: pd.DataFrame, grammar: str):
192202
df = df[df['grammar'] == grammar].copy()
@@ -213,6 +223,7 @@ def display_results_for_grammar(df: pd.DataFrame, grammar: str):
213223
else col
214224
for col in s_edges_df.columns
215225
]
226+
s_edges_df = s_edges_df.applymap(lambda x: format_int(x))
216227
pprint_df(
217228
s_edges_df,
218229
title=f" #ANSWER (grammar '{grammar}') ",

0 commit comments

Comments
 (0)