Skip to content

Use an absolute shared test tolerance - #1240

Closed
karthiksenv wants to merge 1 commit into
stumpy-dev:mainfrom
karthiksenv:codex/use-absolute-test-tolerance
Closed

karthiksenv wants to merge 1 commit into
stumpy-dev:mainfrom
karthiksenv:codex/use-absolute-test-tolerance

Conversation

@karthiksenv

Copy link
Copy Markdown
Contributor

Related to #1175 and the question about the tolerance results.

Store STUMPY_TEST_PRECISION as the absolute tolerance 1.5e-07 requested in the issue checklist, and pass it directly to assert_allclose. This updates 93 active assertions across 17 test files and the corresponding disabled comparisons. A comment in config.py documents the setting's units.

The existing default is 5, which the assertions convert to 1.5 * 10**-5 = 1.5e-05. This change therefore tightens those comparisons by a factor of 100. The algorithm implementations are unchanged.

This is a draft because the stricter tolerance exposes five failing cases. No tolerances were relaxed and no failing assertions were skipped.

Validation on Ubuntu, based on main a42ca40, with Python 3.12.15, NumPy 2.5.4, Numba 0.68.1, seed 3559353816, JIT disabled and CUDA simulated:

Version Affected test cases
Unchanged main, effective atol=1.5e-05 256 passed
This branch, atol=1.5e-07 251 passed, 5 failed

Both runs used the same 42 test functions in the same order. Failures can change subsequent random draws, so the seed alone does not reproduce every case in isolation.

Failing case on this branch Largest failing absolute difference
test_gpu_stump.py::test_gpu_stump_identical_subsequence_self_join 4.03983644e-07
test_mstump.py::test_identical_subsequence_self_join 2.65725769e-07
test_scrump.py::test_scrump_identical_subsequence_self_join[percentages0] 2.06476546e-07
test_stump.py::test_stump_identical_subsequence_self_join 2.22022301e-07
test_stumpi.py::test_stumpi_identical_subsequence_self_join_egress 2.22022301e-07

For example, GPU-STUMP returns 4.03983644e-07 where the reference returns zero. This passes the old tolerance and fails the proposed one.

Black and flake8 passed across the package, tests and included helper scripts. git diff --check passed. An AST comparison confirms that the executable changes consist only of the configured tolerance conversion. The full suite, JIT-enabled tests and hardware CUDA validation have not been run for this branch.

To reproduce the affected selection from either branch, with the versions above installed:

export OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 NUMBA_NUM_THREADS=2
export STUMPY_SEED=3559353816 NUMBA_DISABLE_JIT=1 NUMBA_ENABLE_CUDASIM=1
python - <<'PY'
import ast
from pathlib import Path
import pytest

selectors = []
for path in sorted(Path("tests").glob("test_*.py")):
    for node in ast.parse(path.read_text()).body:
        if (
            isinstance(node, ast.FunctionDef)
            and node.name.startswith("test_")
            and any(
                isinstance(item, ast.Attribute)
                and item.attr == "STUMPY_TEST_PRECISION"
                for item in ast.walk(node)
            )
        ):
            selectors.append(f"{path}::{node.name}")
raise SystemExit(pytest.main(["-q", "-rs", "--tb=short", *selectors]))
PY

Pull Request Checklist

  • Referenced a Github issue
  • Read the issue discussion and checked the open PRs
  • Received maintainer confirmation for the remaining migration work
  • Based the branch on the latest main
  • Created a new branch and made the changes
  • Ran Black and flake8
  • Compared the affected tests before and after the change
  • Ran ./setup.sh dev && ./test.sh and ensured all tests pass

The draft records the failures for discussion before requesting review.

@gitnotebooks

gitnotebooks Bot commented Nov 19, 2026

Copy link
Copy Markdown

Review these changes at https://app.gitnotebooks.com/stumpy-dev/stumpy/pull/1240

@seanlaw seanlaw closed this Nov 19, 2026
@seanlaw

seanlaw commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

This is not needed for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants