test: migrate stats/base/dists/uniform/median to ULP-based assertions - #15418
Merged
Merged
Conversation
Replace relative tolerance comparisons with `isAlmostSameValue` ULP difference assertions in `test.js` and `test.native.js`. Both the JavaScript and C implementations reproduce the Julia fixtures exactly, so the minimum required ULP bound is 0. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H7wkNLFGNTxtsRbFVDWC6b
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/dists/uniform/medianfrom relative tolerance testing to ULP difference testing.delta/tolcomparison intest/test.jsandtest/test.native.jswitht.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );, adding the@stdlib/assert/is-almost-same-valuerequire and removing the now unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires.Final ULP constant:
0for bothtest/test.jsandtest/test.native.js.How the minimum was measured: the conversion started from a bound of
64, and the maximum ULP distance between the returned values and the Julia fixture values was then measured across the full fixture set (1000 values). That maximum is0— every returned value matches its fixture bit-for-bit — so0is both the measured minimum and the tightest bound expressible. This is expected, since the JavaScript implementation computes0.5 * ( a + b )and the C implementation computes( a + b ) / 2.0; scaling by a power of two is exact, so both round identically.The native add-on was built locally so that
test/test.native.jsactually executed rather than being skipped. The full suite (1008 assertions intest.js, 1008 intest.native.js) was run twice at the final bound with identical results, confirming determinism.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
Only the two test files are modified; no source, fixture, or documentation changes.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code as part of an automated, maintainer-configured task for migrating packages to ULP-based test assertions. The conversion mirrors the idiom established in previously merged migrations (e.g.
stats/base/dists/triangular/mean), and the ULP bound was determined empirically by measuring ULP distances over the fixtures and running the package's test suite.@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01H7wkNLFGNTxtsRbFVDWC6b