Skip to content

Fixed #1175 Migrate tests/test_aamp_ostinato.py to npt.assert_allclose - #1182

Open
viknesh-ai wants to merge 1 commit into
stumpy-dev:mainfrom
viknesh-ai:fix/1175-migrate-test-aamp-ostinato
Open

Fixed #1175 Migrate tests/test_aamp_ostinato.py to npt.assert_allclose#1182
viknesh-ai wants to merge 1 commit into
stumpy-dev:mainfrom
viknesh-ai:fix/1175-migrate-test-aamp-ostinato

Conversation

@viknesh-ai

Copy link
Copy Markdown
Contributor

Fixed #1175

Continuing the file-by-file split from #1178/#1181 — this one covers tests/test_aamp_ostinato.py. Will open the next file's PR once this one merges.

assert_almost_equal only checks a fixed absolute tolerance and NumPy's docs recommend assert_allclose instead. 16 call sites in this file, all following the same two fixes established in the previous two PRs:

  • All calls had the naive/stumpy argument order backwards (ref_x, cmp_x instead of cmp_x, ref_x) — flipped every one to put the stumpy-computed value first.
  • The file already used ref_/comp_ naming (radius/Ts_idx/subseq_idx, plus T_comp/Ts_comp in the overwrite-safety tests) — renamed every comp to cmp per the standing convention.

Checked the actual return dtypes from aamp_ostinato before touching anything (radius is float64, Ts_idx/subseq_idx are plain int/int64) — none of them come back dtype=object the way the mixed distance/index arrays in test_aamp.py/test_aamp_motifs.py did, so no .astype(np.float64) casting was needed here. None of the original calls specified decimal=, so every site uses the default atol=1.5e-07.

Ran the full file twice locally (normal mode and JIT-disabled/CUDA-simulated, matching test.sh coverage) — 74/74 passing both times. The dask-backed tests (test_random_ostinatoed, test_deterministic_ostinatoed, etc.) spin up a real LocalCluster, so this one takes noticeably longer than the previous two files (~30-50s locally).

To Do List

Standing checklist from @seanlaw for this migration, applies to every file in the split - status below is for test_aamp_ostinato.py:

  • Each test file correctly replaces all uses of npt.assert_almost_equal with its equivalent npt.assert_allclose
  • When rtol=0 for npt.assert_allclose, simply omit this parameter and value since this is the default
  • Ensure that npt.assert_allclose(actual, desired) always has the stumpy computed value as actual and the naive computation as desired
  • Use atol=1.5e-07 rather than atol=1.5*10**-07
  • Eventually, replace the ugly 1.5*10**-config.STUMPY_TEST_PRECISION with config.STUMPY_TEST_PRECISION = 1.5e-07 (in config.py) - tracked as a follow-up, not part of this per-file migration
  • Use cmp instead of comp - this file used comp_radius/comp_Ts_idx/comp_subseq_idx/T_comp/Ts_comp, all renamed
  • Rename naive outputs to ref_ and stumpy-computed outputs to cmp_ (applies to npt.assert_array_equal too) - this file already used ref_/comp_, no assert_array_equal calls present

Pull Request Checklist

Below is a simple checklist but please do not hesitate to ask for assistance!

  • Read our Contributing Guide
  • Referenced a Github issue (or create one if one doesn't already exist)
  • Read and reviewed all of the comments in the Github issue that you've referenced (along with cross-referenced issues/pull requests) to ensure that the issue still requires a pull request
  • Checked that the issue has not already been assigned to anybody else or is already being addressed in another pull request
  • Left a meaningful comment on the original Github issue to discuss the detailed approach for your contribution and received confirmation from the maintainers before proceeding with this pull request
  • Forked, cloned, and checked out the newest version of the code
  • Created a new branch
  • Made necessary code changes
  • Installed black (i.e., python -m pip install black or conda install -c conda-forge black)
  • Installed flake8 (i.e., python -m pip install flake8 or conda install -c conda-forge flake8)
  • Installed pytest-cov (i.e., python -m pip install pytest-cov or conda install -c conda-forge pytest-cov)
  • Ran black --exclude=".*\.ipynb" --extend-exclude=".venv" --diff ./ in the root stumpy directory
  • Ran flake8 --extend-exclude=.venv ./ in the root stumpy directory
  • Ran ./setup.sh dev && ./test.sh in the root stumpy directory and ensured that all tests are passing locally
  • Check this box if AI code assistance was used to generate 15%+ of the code in this pull request

Please do not commit any code to avoid/circumvent a failing test and, instead, engage in a discussion (below) to determine the best course of action.

Only request a review after the checklist above is fully completed!

@viknesh-ai
viknesh-ai requested a review from seanlaw as a code owner August 14, 2026 04:19
@gitnotebooks

gitnotebooks Bot commented Aug 14, 2026

Copy link
Copy Markdown

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

@viknesh-ai

viknesh-ai commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

@seanlaw next file in the split .Ready for review whenever you have time.

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.

Migrate to npt.assert_allclose

1 participant