Skip to content

Commit 358a476

Browse files
authored
compare.py: add an --only-significant option to filter --statistics results. (#290)
1 parent 0f17633 commit 358a476

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

utils/compare.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,19 @@ def print_result(
316316
sort_by_abs=True,
317317
absolute_diff=False,
318318
lhs_name="lhs",
319-
rhs_name="rhs"
319+
rhs_name="rhs",
320+
only_significant=False
320321
):
321322
metrics = d.columns.levels[0]
322323
if sort_by_abs:
323324
d = d.sort_values(by=(metrics[0], sortkey), key=pd.Series.abs, ascending=False)
324325
else:
325326
d = d.sort_values(by=(metrics[0], sortkey), ascending=False)
326327

328+
if only_significant:
329+
if (metrics[0], 'significant') in d.columns:
330+
d = d[d[(metrics[0], 'significant')] == 'Y']
331+
327332
# Ensure that the columns are grouped by metric (rather than having the
328333
# diffs at the end of the line).
329334
d = d.reindex(columns=d.columns.levels[0], level=0)
@@ -494,6 +499,13 @@ def main():
494499
default=0.05,
495500
help="Significance level for statistical tests (default: 0.05)",
496501
)
502+
parser.add_argument(
503+
"--only-significant",
504+
action="store_true",
505+
dest="only_significant",
506+
default=False,
507+
help="Show only significant results when used with --statistics",
508+
)
497509
config = parser.parse_args()
498510

499511
if config.show_diff is None:
@@ -636,6 +648,7 @@ def main():
636648
config.absolute_diff,
637649
config.lhs_name,
638650
config.rhs_name,
651+
config.only_significant,
639652
)
640653

641654

0 commit comments

Comments
 (0)