test: migrate stats/base/snanstdev to ULP-based assertions - #15216
Merged
Merged
Conversation
Replaces manual EPS-based tolerance checks with `isAlmostSameValue`-based ULP assertions in the float32 population standard deviation tests. Ref: #11352 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NK6DcZzirTjPVrQb1Rh72c --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: skipped - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
Member
Author
|
An automated check found potentially unrelated issue/PR references in this PR:
Why this matters: GitHub automatically closes issues referenced with What to do:
This assessment was generated by an AI model and is informational only. Generated by Claude Code |
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
kgryte
reviewed
Sep 15, 2026
Co-authored-by: Athan <kgryte@gmail.com> Signed-off-by: Athan <kgryte@gmail.com>
kgryte
approved these changes
Sep 15, 2026
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/snanstdevfrom a computed relative-tolerance comparison (delta = abs( v - expected )/tol = 1.0 * EPS * abs( expected ), asserted viat.strictEqual( delta <= tol, ... )) to a ULP-difference assertion using@stdlib/number/float32/base/assert/is-almost-same-value.test/test.snanstdev.js,test/test.snanstdev.native.js,test/test.ndarray.js, andtest/test.ndarray.native.js.@stdlib/math/base/special/absand@stdlib/constants/float32/epsrequires from each file, along with thedeltaandtolvariable declarations, replacing them with a single namedULPconstant declared at the top of the affected test body.t.strictEqualcomparisons against bit-identicalfloat64ToFloat32( sqrt( ... ) )results and was left unchanged.Only test files are changed; no implementation, fixture, or documentation changes are included.
ULP bounds
NaN(2 fixtures, all 4 test files)1.0 * EPS * abs( expected )(float32EPS)1This is the minimum integer bound
Nsuch thatisAlmostSameValue( v, expected, N )holds at both fixture values in every one of the four test files. AtN = 1each file's full suite passes (36/36 for the non-native variants; the native variants skip, as no native addon is built in this environment). AtN = 0, 2 of the 36 assertions fail in both the non-nativetest.snanstdev.jsandtest.ndarray.jsfiles, so no tighter bound exists.Each non-native test file (
test.snanstdev.js,test.ndarray.js) was run twice at the final bound vianpx tapewith identical results (36/36 passing, no failures), ruling out FMA/architecture-dependent flakiness on this platform.npx eslinton all four changed files is clean.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
The migration mirrors the idiom used in already-merged conversions for other float32 strided packages, notably
blas/base/srotmandblas/base/drotm, which use@stdlib/number/float32/base/assert/is-almost-same-value(aliasedisAlmostSameValuef) rather than the float64@stdlib/assert/is-almost-same-value, since the compared values (vandexpected) are float32-precision quantities produced viafloat64ToFloat32.Two environment notes, neither of which affected verification:
make install-node-modulesinitially failed withETARGETfores-object-atoms@^1.1.2: that version was published to the npm registry and then unpublished, but several transitive dependents (array-includes,string.prototype.trim,string.prototype.trimend, etc.) still declare it as their required range. Installed with a temporary root-leveloverridespin toes-object-atoms@1.1.1for this one-time setup; theoverridesfield itself was never part of, and is not included in, this PR's diff.pre-commithook'slint-editorconfig-filesstep could not run, because it downloads theeditorconfig-checkerbinary from a GitHub release that this environment cannot reach (network access is scoped to thestdlib-js/stdlibrepository only). The changed files were instead checked manually against.editorconfig: LF line endings, tab indentation, no trailing whitespace, and a final newline in all four files.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code, running as an unattended scheduled task. It selected the package by searching the repository for the old tolerance idiom and cross-checking against open/merged ULP-migration PRs to avoid collisions, studied previously migrated float32 packages to match the established idiom, performed the migration across all four test files, and determined the minimum passing ULP bound empirically at the assertion site.
@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01NK6DcZzirTjPVrQb1Rh72c
Generated by Claude Code