diff --git a/test/scripts/fuzzer.py b/test/scripts/fuzzer.py index e8109c7..7599228 100755 --- a/test/scripts/fuzzer.py +++ b/test/scripts/fuzzer.py @@ -400,11 +400,20 @@ def compute_stats(df: pd.DataFrame, keep_nans: bool, keep_infs: bool) -> Dict: def compare_metric( - worker_id: int, q1: str, q2: str, metric: str, expected, found, keep_nans: bool, keep_infs: bool + worker_id: int, + q1: str, + q2: str, + metric: str, + expected, + found, + keep_nans: bool, + keep_infs: bool, + rtol: float = 1.0e-5, + atol: float = 1.0e-8, ) -> bool: do_numeric_comparison = expected is not None and found is not None if do_numeric_comparison: - if not np.isclose(expected, found, equal_nan=True): + if not np.isclose(expected, found, rtol=rtol, atol=atol, equal_nan=True): logging.warning( "[%d] %s, %s (%s; keep_nans=%s; keep_infs=%s): FAIL! Expected %.16g, found %.16g", worker_id, @@ -437,8 +446,8 @@ def compare_metric( def compare_query_stats(worker_id: int, q1: str, q2: str, expected, sel: hictkpy.PixelSelector) -> int: - exact_metrics = ["nnz", "sum", "min", "max", "min", "skewness", "kurtosis"] - approx_metrics = ["variance"] + exact_metrics = ["nnz", "sum", "min", "max", "min"] + approx_metrics = ["variance", "skewness", "kurtosis"] num_failures = 0 for keep_nans in [True, False]: for keep_infs in [True, False]: @@ -454,7 +463,7 @@ def compare_query_stats(worker_id: int, q1: str, q2: str, expected, sel: hictkpy for metric in approx_metrics: n1 = stats_expected[metric] n2 = stats_found[metric] - if not compare_metric(worker_id, q1, q2, metric, n1, n2, keep_nans, keep_infs): + if not compare_metric(worker_id, q1, q2, metric, n1, n2, keep_nans, keep_infs, 1.0e-4, 1.0e-6): num_failures += 1 return int(num_failures != 0)