Repository navigation
test: migrate stats/base/dists/t/variance to ULP-based assertions - #16020
Merged
Merged
Conversation
Replaces the computed relative tolerance comparison in the native test fixture loop with a ULP-based assertion. The measured minimum required ULP difference over the full fixture set is zero for both the JavaScript and C implementations, which is consistent with the exact assertions already used in `test/test.js`. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJ2JUhP1NnZRW3mrjB7UpH
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
kgryte
marked this pull request as ready for review
October 11, 2026 12:36
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/t/variancefrom relative tolerance assertions to ULP-based assertions using@stdlib/assert/is-almost-same-value.Only
test/test.native.jscontained the computed-tolerance idiom (delta = abs( y - expected[ i ] )/tol = 2.0 * EPS * abs( expected[ i ] )), so that is the only file changed. The fixture loop intest/test.jsalready used exact assertions, and, per the guidance in #11352 to avoid extraneous test changes, it has been left as is.Final ULP constant:
0.The bound was measured rather than guessed. For every one of the 50 fixture cases, the smallest
maxULPsatisfyingisAlmostSameValue( y, expected[ i ], maxULP )was computed for both the JavaScript and the C implementation; the maximum over the fixture set is0in both cases. In other words, both implementations reproduce the Julia fixtures bit-for-bit, so0is the tightest admissible bound and no padding was added. This is consistent withtest/test.js, which already asserted exact equality, and it means the oldelsebranch was in practice unreachable on this fixture set.A
0ULP bound is well-established in the codebase for this situation; for example,stats/base/dists/beta/meanandstats/base/dists/beta/skewnessuseisAlmostSameValue( y, expected[ i ], 0 )in their fixture loops.Verification
make install-node-addons NODE_ADDONS_PATTERN="stats/base/dists/t/variance"), so thetest.native.jsassertions actually execute rather than being skipped:test/test.jsreports 58 passing andtest/test.native.jsreports 59 passing.make test TESTS_FILTER=".*/stats/base/dists/t/variance/.*"was run twice at the final bound, with identical results both times (no arch/FMA-dependent variation).eslintis clean againstetc/eslint/.eslintrc.tests.js, andlint-license-headers-filespasses.test/test.native.js.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
One, on a judgment call: since the measured minimum is
0andtest/test.jswas already exact, an alternative reading is that this package has no tolerance to migrate and should be skipped entirely. This PR instead removes the dead tolerance branch and states the0ULP budget explicitly, matching thebeta/meanprecedent. Happy to close this if you would rather leave such packages untouched.Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written by Claude Code running as an unattended scheduled task. It selected the package, mirrored the conversion idiom from already-merged PRs in the same family, measured the ULP bound programmatically over the full fixture set, and ran the tests and linters locally. The changes have not been reviewed by a human prior to submission, which is why it is opened as a draft.
@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01JJ2JUhP1NnZRW3mrjB7UpH
Generated by Claude Code