Repository navigation
test: migrate stats/base/snanstdevch to ULP-based assertions - #16125
Merged
Merged
Conversation
Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KdBJCQoMkXncAATzNSWsej
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves a part of #11352.
Description
This pull request:
stats/base/snanstdevchfrom relative tolerance testing to ULP difference testing.delta = abs( v - expected ); tol = 1.0 * EPS * abs( expected );comparisons withisAlmostSameValuef( v, expected, <ULP> )assertions, adding the@stdlib/number/float32/base/assert/is-almost-same-valuerequire and dropping the now unused@stdlib/math/base/special/absand@stdlib/constants/float32/epsrequires.As the package returns single-precision results, this follows the already migrated sibling packages
stats/base/snanstdevyc,stats/base/snanstdevwd, andstats/base/snanstdevpn, which use the single-precision@stdlib/number/float32/base/assert/is-almost-same-valuerather than the double-precision assertion.Four test files are modified (
test/test.snanstdevch.js,test/test.snanstdevch.native.js,test/test.ndarray.js, andtest/test.ndarray.native.js);test/test.jscontains no tolerance-based assertions and is left unchanged. The native test files receive the same bound as their JavaScript counterparts, as the C implementation was measured to return bit-identical results for these inputs.ULP bounds
Each of the eight migrated assertions has a measured ULP difference of exactly
1, so the final bound is 1 throughout. This was verified to be minimal: lowering any bound to0fails the suite.test/test.snanstdevch.jstest/test.snanstdevch.native.jstest/test.ndarray.jstest/test.ndarray.native.jsThis matches the bound used by the migrated sibling packages
stats/base/snanstdevycandstats/base/snanstdevwd, which exercise the same datasets against a different summation algorithm.The native add-on was compiled locally (
make install-node-addons NODE_ADDONS_PATTERN=snanstdevch) so that the.native.jstest files actually execute rather than being skipped. The full suite was run twice at the final bounds with identical results (149 assertions, all passing, across all five test files).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 lint-javascript-tests TESTS_FILTER=".*/stats/base/snanstdevch/.*"passes cleanly. The migration also removes two over-long lines per test file, matching the line lengths of the already migrated sibling packages.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code, which performed the migration, measured the minimum ULP bounds empirically, and verified the test suite.
@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01KdBJCQoMkXncAATzNSWsej
Generated by Claude Code