Repository navigation
test: migrate stats/base/dists/discrete-uniform/quantile to ULP-based assertions - #15926
Merged
Merged
Conversation
…ed assertions Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VdWTZQyfuCaFizioXQ6JKf
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/discrete-uniform/quantilefrom relative tolerance testing to ULP difference testing, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.The computed
delta/tolcomparisons in the fixture loops oftest/test.quantile.js,test/test.factory.js, andtest/test.native.jsare replaced withisAlmostSameValue( y, expected[ i ], 0 )assertions, and the now-unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires are dropped in favor of@stdlib/assert/is-almost-same-value. No other test cases were touched; the exact comparisons elsewhere in these files are unchanged.test/test.jscontains no tolerance-based assertions and is therefore unmodified.The ULP bound is the measured minimum over each full fixture set:
fixtures/julia/small_range.jsonfixtures/julia/medium_range.jsonfixtures/julia/large_range.jsonEach fixture set contains 1000 cases. Starting from a loose bound and tightening, every one of the 3000 cases is bit-identical to the Julia-generated expected value for both implementations under test (
lib/main.jsandlib/factory.js), so the measured maximum ULP difference is 0 andtest.factory.jsuses the same bound astest.quantile.js. BecausemaxULP = 0requiresisSameValueequality, it is the tightest integer bound attainable and no smaller value exists to check.This result is expected: the quantile function evaluates
a + floor( p*(b-a+1) ), which, for the integer supports exercised by the fixtures, is exactly representable in double precision.The same bound holds for the C implementation. The native add-on was built locally (
node-gyp rebuild) so thattest/test.native.jsactually runs rather than being skipped, and all 3007 of its assertions pass at0ULP. As a cross-check against FMA/arch sensitivity, the C expression was additionally evaluated over the same 3000 fixture cases in a standalone harness compiled both at-O2and at-O3 -march=native -ffp-contract=fast; both produced bit-identical results for every case.The suite was run twice at the final bound, with identical results both times (3016 + 3012 + 3 + 3007 assertions passing, 0 failing).
Note that the previous bound was
1.0 * EPSin all nine fixture loops; the0ULP bound is strictly tighter.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/dists/discrete-uniform/quantile/.*"is clean.stats/base/dists/erlang/quantileandstats/base/dists/chisquare/quantile.make lint-editorconfig-filescould not run in this environment, as theeditorconfig-checkerbinary could not be downloaded. The changed lines were checked by hand for tab indentation, trailing whitespace, line endings, and a final newline.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written by Claude Code, which also measured the minimum ULP bound empirically and ran the tests and linter.
@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01VdWTZQyfuCaFizioXQ6JKf
Generated by Claude Code