Repository navigation
Migrate to npt.assert_allclose #1175
Description
Activity
- addedenhancementNew feature or requestNew feature or request
on Aug 5, 2026 Agreed ,assert_almost_equal only checks absolute tolerance (abs(actual-desired) < 1.510**-decimal), while assert_allclose combines relative + absolute (atol + rtolabs(desired)), so it's more meaningful for comparisons across varying magnitudes and matches what NumPy recommends.
I count 1283 call sites across 40 test files currently using assert_almost_equal (only 2 already use assert_allclose), so this is a fairly mechanical but wide-reaching change. Proposing two passes: first a straight swap to assert_allclose(a, b, atol=1.5*10**-decimal, rtol=0) everywhere, which preserves today's exact pass/fail behavior with no risk, then a follow-up pass to set meaningful rtol/atol case-by-case where a relative tolerance is actually the right thing to check (the rtol=1e-12, atol=1e-12 used in the #1174 MASS precision tests is a decent template for that). I can start on pass 1 if that approach sounds good to you.
- added 3 commits that reference this issue
on Aug 9, 2026 - added a commit that references this issue
on Aug 13, 2026 - added a commit that references this issue
on Aug 14, 2026 @viknesh-ai Please continue when you get a chance. Perhaps, let's do three PRs at a time?
@viknesh-ai I am ready for more! 👍
@viknesh-ai Are you able to continue contributing to this issue?
According to the NumPy docs for
npt.assert_almost_equal:Perhaps, we should migrate our tests accordingly?
To Do List
npt.assert_almost_equalornpt.assert_array_almost_equalwith its equivalent npt.assert_allclose (check withgrep assert*_almost tests/*)npt.assert_array_equal(actual, desired)always has the stumpy computed value as "actual" and the naive computation as "desired"1.5*10**-config.STUMPY_TEST_PRECISIONwithconfig.STUMPY_TEST_PRECISION = 1.5e-07(inconfig.py)compwithcmpref_and stumpy-computed outputs tocmp_(applies tonpt.assert_array_equaltoo)