Repository navigation
test: migrate stats/base/dists/triangular/variance to ULP-based assertions - #14425
Merged
Merged
Conversation
…ertions Replaces EPS-scaled relative tolerance comparisons (and, in the native test, `toFixed( 4 )` string comparisons) with `isAlmostSameValue` assertions. Over the full 500-value Julia fixture set, both the JavaScript and native implementations reproduce the expected values bit-for-bit, so the tightest passing bound is 0 ULP. Ref: #11352 Claude-Session: https://claude.ai/code/session_01PjUefgKYy3gQjkssALyEzH
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
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 |
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.
Ref #11352.
Description
This pull request:
stats/base/dists/triangular/variancefrom computed floating-point tolerances to ULP-based assertions, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.delta/tol(EPS * abs( expected[i] )) comparison intest/test.jswithisAlmostSameValue( y, expected[ i ], 0 ).toFixed( 4 )string comparison anddelta/tolfallback intest/test.native.jswithisAlmostSameValue( y, expected[ i ], 0 ).@stdlib/assert/is-almost-same-valuerequire and drops the now unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires.Final ULP bound:
0in bothtest/test.jsandtest/test.native.js.Measured minimum: starting from a high bound and tightening, the minimum integer bound which passes over the full fixture set is
0, i.e. both implementations reproduce every fixture value bit-for-bit. Over all 500 Julia fixture values, the maximum ULP difference is0for the JavaScript implementation and0for the native implementation (the native add-on was built locally so thattest/test.native.jsactually executed rather than being skipped). The full suite (1018 assertions across both test files) was run twice at the final bound with identical results, so no FMA/arch-related nondeterminism was observed on this platform (Linux x86-64, gcc).This is expected: the JavaScript and C implementations evaluate the identical expression
( (a*a) + (b*b) + (c*c) - (a*b) - (a*c) - (b*c) ) / 18.0, so absent FMA contraction the two agree exactly with the reference values.Only the two test files are modified; no source, documentation, benchmark, or fixture files are touched.
Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
0meansisAlmostSameValuefalls back toSameValuesemantics (as is the case elsewhere in the repository, where0is already used in a number of converted packages). If reviewers would prefer to retain a single ULP of headroom intest/test.native.jsto guard against FMA contraction on architectures where the C compiler fuses the multiply-adds (e.g. arm64), the native bound can be relaxed to1. As measured on x86-64,0passes.Other
make lint-javascript-files ESLINT_CONF=etc/eslint/.eslintrc.tests.js, andgit statusconfirms only the two test files changed.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code, which selected the package, mirrored the conversion idiom used in previously converted packages, measured the ULP bound against the fixture set, and verified tests and linting.
@stdlib-js/reviewers
Generated by Claude Code