Repository navigation
test: migrate stats/base/dists/binomial/variance to ULP-based assertions - #15614
Merged
Merged
Conversation
…tions Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H6PY1ZMhsqMSqnD3RU5UcY
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
kgryte
marked this pull request as ready for review
September 28, 2026 03:11
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/binomial/variancefrom relative tolerance assertions to ULP difference assertions using@stdlib/assert/is-almost-same-value.test/test.native.js, replacing theif ( y === expected[i] ) { ... } else { delta/tol }branch against2.0 * EPS * abs( expected[ i ] )witht.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );and dropping the now-unusedabsandEPSrequires.test/test.jsis not modified: its fixture loop already performs an exact comparison (t.strictEqual( y, expected[i], ... )) and contains no computed tolerance, so there is nothing to migrate there.ULP bound
The ULP constant is
0, which is the measured minimum over the full Julia fixture set (200 cases):N = 0Every one of the 200 fixture values is returned bit-identically by both implementations, so
0is the tightest achievable bound and the2.0 * EPSslack in the previous assertion was never exercised. This is expected from the implementations: bothlib/main.jsandsrc/main.cevaluate the same expression,n * p * ( 1.0 - p ), which contains no fused-multiply-add contraction opportunity and is therefore reproducible across platforms.The native addon was compiled locally (
npx node-gyp rebuild) so thattest/test.native.jsexecuted against the C implementation rather than being skipped — the native file reports 207 passing assertions (200 fixtures plus 7 argument-validation assertions), which confirms the fixture loop ran and was not skipped. The suite was run twice atN = 0to confirm determinism: 214 passing assertions intest/test.jsand 207 intest/test.native.json both runs, with no failures and no skips.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
test/test.native.jsis changed.make test TESTS_FILTER=".*/stats/base/dists/binomial/variance/.*"is green, andmake lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/binomial/variance/.*"is clean. The conversion mirrors the idiom used in the sibling packagestats/base/dists/binomial/skewness(#15427) and, for theN = 0case specifically,stats/base/dists/invgamma/mode(#15502).The EditorConfig linter could not be run in this environment because its binary could not be downloaded, so EditorConfig compliance (LF line endings, UTF-8, tab indentation, no trailing whitespace, final newline) was verified manually instead.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code, which performed the mechanical tolerance-to-ULP conversion, measured the minimum ULP bound empirically against the fixture set, built the native addon, and ran the tests and test linter locally.
@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01H6PY1ZMhsqMSqnD3RU5UcY
Generated by Claude Code