test: migrate stats/incr/nancovariance to ULP-based assertions - #14571
Merged
Conversation
Ref: #11352 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BuySsNNMLd6DU7uuU4kLHc
Contributor
Coverage ReportNo coverage information available. |
Member
|
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 |
Signed-off-by: Athan <kgryte@gmail.com>
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/incr/nancovariancefrom relative tolerance testing to ULP difference testing, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.delta/tolcomparison intest/test.jswitht.strictEqual( isAlmostSameValue( cov, expected, 0 ), true, 'returns expected value' );, adding the@stdlib/assert/is-almost-same-valuerequire and dropping the now unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires.ULP bound:
0, the measured minimum. The package has notest/test.native.js, sotest/test.jsis the only test file changed.The bound was determined empirically rather than assumed. Starting from a high bound and lowering it, the accumulated covariance for the fixture sequence in the affected test is bit-identical to the expected value
14/3: the measured ULP difference between the returned value (4.666666666666667) and the expected value is exactly0, so the bound cannot be tightened further. The suite was then run twice at the final bound with identical results (15/15 passing in each run), so the bound is not sensitive to run-to-run variation.A bound of
0is stable here because the accumulator is pure double-precision JavaScript arithmetic:stats/incr/nancovariancedelegates tostats/incr/covariance, whose Welford-style update uses only IEEE-754 addition, subtraction, multiplication, and division, all of which are correctly rounded and reproducible across platforms (JavaScript performs no FMA contraction). The previous relative tolerance wasEPS * abs( expected ), i.e. roughly one ULP at this magnitude, so0sits within the prior accuracy budget rather than loosening it.Only the one test file is modified; no implementation, fixture, or documentation changes are included.
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
Notes on local verification:
make test TESTS_FILTER=".*/stats/incr/nancovariance/.*"passes 15/15 assertions, run twice.make lint-javascript-tests TESTS_FILTER=".*/stats/incr/nancovariance/.*"reports no problems.make install-node-modulesinitially failed in this environment because the local npm cache held a stale packument fores-object-atoms, causinges-object-atoms@^1.1.2to resolve as nonexistent. Clearing the npm cache resolved it; no repository files were involved.make lint-editorconfig-files(run via the pre-commit hook) could not execute because theeditorconfig-checkerbinary download is blocked in this environment. The changed file was instead checked manually for indentation (tabs), trailing whitespace, line endings (LF), and final newline, and matches the surrounding files exactly.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code running as an unattended scheduled task. It studied previously merged conversions under #11352 (including the
stats/incr/nanskewnesssibling) to match the established idiom, applied the migration, measured the minimum ULP bound empirically against the values exercised by the test, and verified that the tests pass and that the file lints cleanly.@stdlib-js/reviewers
Generated by Claude Code