ci.eval.compare: make the table format using tabulate not manually
This commit is contained in:
@@ -95,25 +95,16 @@ def dataframe_to_markdown(df: pd.DataFrame) -> str:
|
|||||||
|
|
||||||
# Header (get column names and format them)
|
# Header (get column names and format them)
|
||||||
headers = [str(column) for column in df.columns]
|
headers = [str(column) for column in df.columns]
|
||||||
table = []
|
table = [
|
||||||
|
[
|
||||||
# Iterate over rows to build Markdown rows
|
row["metric"],
|
||||||
for _, row in df.iterrows():
|
|
||||||
# Check for no change and NaN in p_value/t_stat
|
# Check for no change and NaN in p_value/t_stat
|
||||||
row_values = []
|
*[None if np.isnan(val) or np.allclose(val, 0) else val for val in row[1:]],
|
||||||
for val in row:
|
]
|
||||||
if isinstance(val, (float, int)):
|
for _, row in df.iterrows()
|
||||||
if np.isnan(val):
|
]
|
||||||
row_values.append("-") # Custom symbol for NaN
|
|
||||||
elif val == 0:
|
|
||||||
row_values.append("-") # Custom symbol for no change
|
|
||||||
else:
|
|
||||||
row_values.append(f"{val:.4f}")
|
|
||||||
else:
|
|
||||||
row_values.append(str(val))
|
|
||||||
table.append(row_values)
|
|
||||||
|
|
||||||
return tabulate(table, headers, tablefmt="github")
|
return tabulate(table, headers, tablefmt="github", floatfmt=".4f", missingval="-")
|
||||||
|
|
||||||
|
|
||||||
def perform_pairwise_tests(before_metrics: dict, after_metrics: dict) -> pd.DataFrame:
|
def perform_pairwise_tests(before_metrics: dict, after_metrics: dict) -> pd.DataFrame:
|
||||||
|
|||||||
Reference in New Issue
Block a user