From 92a07c53e2e9bcf4a8a16f96cbefb6c8144cef6e Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk <21087696+oleksandr-pavlyk@users.noreply.github.com> Date: Mon, 29 Jun 2026 16:11:56 -0500 Subject: [PATCH] Clarify nvbench-compare validation helpers and CLI help Factor finite-value checks through a common helper so positive and non-negative finite predicates share the same None/finite guard. Add a comment explaining the positive lower-bound clamp used for mean/stdev intervals, since later ratio and log-distance checks require positive bounds. Also quote the --axis pow2 example in CLI help so shell users can copy the example safely. --- python/scripts/nvbench_compare.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/python/scripts/nvbench_compare.py b/python/scripts/nvbench_compare.py index 2d4bb44..593c85c 100644 --- a/python/scripts/nvbench_compare.py +++ b/python/scripts/nvbench_compare.py @@ -1240,12 +1240,16 @@ def compute_relative_dispersion(dispersion, center): return dispersion / center +def is_finite(value): + return value is not None and math.isfinite(value) + + def is_positive_finite(value): - return value is not None and value > 0.0 and math.isfinite(value) + return is_finite(value) and value > 0.0 def is_nonnegative_finite(value): - return value is not None and math.isfinite(value) and value >= 0.0 + return is_finite(value) and value >= 0.0 def derive_absolute_dispersion(relative_dispersion, center): @@ -1305,6 +1309,7 @@ def compute_mean_summary_interval(timing): if not is_positive_finite(timing.mean) or not is_nonnegative_finite(timing.stdev): return None + # Keep the lower bound positive so later ratio/log-distance checks are defined. lower = max(timing.mean - timing.stdev, timing.mean * 0.001) upper = timing.mean + timing.stdev if is_positive_finite(timing.minimum): @@ -3332,7 +3337,7 @@ def main() -> int: dest="filter_actions", action=OrderedBenchmarkFilterAction, help=( - "Filter on axis value, e.g. -a Elements{io}[pow2]=20. Applies to the " + "Filter on axis value, e.g. -a 'Elements{io}[pow2]=20'. Applies to the " "most recent --benchmark, or all benchmarks if specified before any " "--benchmark arguments." ),