test: migrate stats/strided/sstdevwd to ULP-based assertions - #15302
Conversation
Migrate the tests for `stats/strided/sstdevwd` from relative tolerance testing to ULP difference testing, replacing the `delta`/`tol` comparisons with `isAlmostSameValuef` assertions using the minimum required ULP bound of `1`. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QMgxvv2enPsho3aBY8NYSV
|
Hello! 👋 We've noticed that you've been opening a number of PRs addressing good first issues. Thank you for your interest and enthusiasm! Now that you've made a few contributions, we suggest no longer working on good first issues. Instead, we encourage you to prioritize cleaning up any PRs which have yet to be merged and then proceed to work on more involved tasks. Not only does this ensure that other new contributors can work on things and get ramped up on all things stdlib, it also ensures that you can spend your time on more challenging problems. 🚀 For ideas for future PRs, feel free to search the codebase for TODOs and FIXMEs and be sure to check out other open issues on the issue tracker. Cheers! |
Coverage Report
The above coverage report was generated for the changes in this PR. |
Resolves a part of #11352.
Description
This pull request:
stats/strided/sstdevwdfrom relative tolerance testing to ULP difference testing, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.delta/tolcomparisons intest/test.sstdevwd.js,test/test.ndarray.js,test/test.sstdevwd.native.js, andtest/test.ndarray.native.jswitht.strictEqual( isAlmostSameValuef( v, expected, 1 ), true, 'returns expected value' ), adding the@stdlib/number/float32/base/assert/is-almost-same-valuerequire and removing the now unused@stdlib/math/base/special/absand@stdlib/constants/float32/epsrequires.Because this package operates on single-precision floating-point numbers, the single-precision assertion utility
@stdlib/number/float32/base/assert/is-almost-same-valueis used, matching already-migrated single-precision packages (e.g.,stats/base/snanstdevpn,stats/base/snanstdev).Final ULP constant:
1for all four assertions (one assertion × four test files).The bound was tightened by starting high (
64) and lowering it to the minimum integer which still passes over the full set of test cases. The measured ULP difference was1for every assertion, in both the JavaScript and the C implementation:test.sstdevwd.jstest.ndarray.jstest.sstdevwd.native.jstest.ndarray.native.jsA bound of
0fails (the returned value and the reference value are adjacent single-precision numbers:2.986078977584839vs.2.9860787391662598), so1is the tightest passing bound.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
No.
Other
make test TESTS_FILTER=".*/stats/strided/sstdevwd/.*"was run twice at the final ULP bound with identical results (41 passing, 0 failing), to rule out arch/FMA nondeterminism.test/test.sstdevwd.native.jsandtest/test.ndarray.native.jsreported as skipped. To confirm the1ULP bound for the C implementation,src/main.c(together withstats/strided/svariancewd,math/base/special/sqrtf, andstrided/base/stride2offset) was compiled standalone and the same cases were evaluated; the measured ULP difference was1at-O0,-O2, and-O3 -march=native -ffp-contract=fast, with the C implementation returning bit-for-bit the same value as the JavaScript implementation. Reviewers may wish to confirm the native tests on CI, where the add-on is actually built.test/directory using the repository's own test configuration (make eslint-tests): 0 errors, 0 warnings across all five test files.lint-filenamesandlint-license-headers-filesalso passed.lint-editorconfigcould not be executed, becauseeditorconfig-checkerdownloads its binary from GitHub releases, which was not reachable from this environment. The changed files were instead verified programmatically against every rule.editorconfigapplies to*.js: LF line endings, UTF-8 encoding, tab indentation, no trailing whitespace, and a final newline.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code, which selected the package, mirrored the idiom used by already-migrated packages, measured the minimum passing ULP bound over the full set of test cases, and verified the tests and linting locally.
@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01QMgxvv2enPsho3aBY8NYSV
Generated by Claude Code