test: migrate stats/base/dists/lognormal/variance to ULP-based assertions - #14069
Merged
Conversation
…rtions Migrates the tests for `stats/base/dists/lognormal/variance` from computed relative tolerance checks to ULP-based assertions using `@stdlib/assert/is-almost-same-value`. The ULP bound was tightened to the measured minimum (0) over the full fixture set for both the JavaScript and compiled C implementations. Ref: #11352
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
Planeshifter
approved these changes
Aug 8, 2026
kgryte
marked this pull request as ready for review
August 8, 2026 23:27
This was referenced Aug 9, 2026
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/lognormal/variancefrom computed relative tolerance testing (delta = abs( y - expected[i] ),tol = 1.0 * EPS * abs( expected[i] ),t.ok( delta <= tol, ... )) to ULP difference testing using@stdlib/assert/is-almost-same-value.test/test.jsandtest/test.native.js, which mirror one another.@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires from both test files (neither is used elsewhere in these files).ULP bounds (tightened to the measured minimum over the full fixture set):
fixtures/julia/data.json0Notes on how the bound was determined:
0is both the measured maximum and the tightest possible bound.Nfor whichisAlmostSameValue( y, expected[i], N )istrue, and taking the maximum over the fixture set. Starting from a bound of64and lowering, the suite passes all the way down to0.( exp( s2 ) - 1 ) * exp( ( 2*mu ) + s2 )withs2 = sigma^2, and the JavaScript and C implementations evaluate exactly the same expression using the same underlyingexpkernel, leaving no room for the two to diverge on these inputs.y === expected[i]fast path was taken for every fixture value and the tolerance branch was never exercised.test.jsandtest.native.jsuse identical bounds.node-gyp rebuild), sotest/test.native.jswas exercised against the actual C implementation rather than skipped. Both test files were run twice at the final bound with identical results (110 assertions fortest.js, 111 fortest.native.js, all passing, per run), so the bound is not sensitive to FMA/contraction differences on this machine.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
Two minor points:
if ( expected[i] !== null )guard was retained in both loops in order to keep the diff limited to the tolerance math. The current fixture data contains nonullentries, so the guard is presently inert and could be dropped if reviewers prefer.0is equivalent to a strict equality check.isAlmostSameValue( ..., 0 )was chosen for consistency with the other converted packages, matching the approach taken instats/base/dists/erlang/skewness(test: migratestats/base/dists/erlang/skewnessto ULP-based assertions #14022).Other
make test TESTS_FILTER=".*/stats/base/dists/lognormal/variance/.*"and by running both test files directly against the compiled add-on. Linting is clean via ESLint usingetc/eslint/.eslintrc.tests.js.editorconfigpre-commit hook could not run in this environment, as it downloads its binary from a host this session cannot reach. The two files were instead checked against.editorconfig(LF endings, tab indentation, final newline, UTF-8); the diff introduces no new violations.stats/base/dists/erlang/skewness(test: migratestats/base/dists/erlang/skewnessto ULP-based assertions #14022), which uses an inline integer ULP argument per fixture loop and the'returns expected value'assertion message.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code, running as an unattended scheduled task. The test migration follows the idiom established by previously merged conversions, and the ULP bound was measured empirically against both the JavaScript and compiled C implementations rather than guessed.
@stdlib-js/reviewers
Generated by Claude Code