From 9c50b2a61025238b1268926c5879fba93ed7152f Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Fri, 31 Jul 2026 17:30:35 +0200 Subject: [PATCH 1/2] test: fix `is_constant` benchmark variation --- tests/test_stats.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_stats.py b/tests/test_stats.py index 6d1b1cc..8eddd88 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -398,4 +398,12 @@ def test_stats_benchmark( arr = array_type.random((n, n), density=density, dtype=dtype) func(arr, axis=axis) # warmup: numba compile - benchmark(func, arr, axis=axis) + + is_very_fast = func is stats.is_constant and ((array_type.name == "csr_array" and axis == 1) or (array_type.name == "csc_array" and axis == 0)) + + def call(a: CpuArray, axis: Literal[0, 1] | None) -> None: + reps = 100 if is_very_fast else 1 + for _ in range(reps): + func(a, axis=axis) + + benchmark(call, arr, axis=axis) From 4aca25fa76e1640e88f7c2be843ceb3c1bec3a0d Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Fri, 31 Jul 2026 17:35:11 +0200 Subject: [PATCH 2/2] simpler --- tests/test_stats.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/test_stats.py b/tests/test_stats.py index 8eddd88..993020a 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -401,9 +401,7 @@ def test_stats_benchmark( is_very_fast = func is stats.is_constant and ((array_type.name == "csr_array" and axis == 1) or (array_type.name == "csc_array" and axis == 0)) - def call(a: CpuArray, axis: Literal[0, 1] | None) -> None: - reps = 100 if is_very_fast else 1 - for _ in range(reps): - func(a, axis=axis) - - benchmark(call, arr, axis=axis) + @benchmark + def call() -> None: + for _ in range(100 if is_very_fast else 1): + func(arr, axis=axis)