test: migrate stats/base/dists/beta/kurtosis to ULP-based assertions - #15180
Merged
Conversation
Migrate the computed relative tolerance assertions to ULP difference assertions using `@stdlib/assert/is-almost-same-value`. Both the JavaScript and C implementations reproduce the reference fixture values bit-for-bit, and thus the minimum required ULP bound is zero. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018pww2eTE6dBtB2G1jEpVDr
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/beta/kurtosisfrom computed relative-tolerance comparisons (delta = abs( y - expected[ i ] )/tol = 1.0 * EPS * abs( expected[ i ] ), asserted viat.ok( delta <= tol, ... )) to ULP-difference assertions using@stdlib/assert/is-almost-same-value.test/test.js(JavaScript implementation) and one intest/test.native.js(C implementation). Both iterate over the same 1000-pointtest/fixtures/julia/data.jsonfixture.if ( y === expected[i] ) { ... } else { ... }branch at each site into a single ULP assertion, and standardizes the assertion message to'returns expected value'.@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires and thedeltaandtolvariable declarations.The remaining assertions in these files are exact comparisons (
NaNpropagation forNaN, non-positive, and infinite parameters, along with function type checks), which are correct as-is and are left unchanged.Only test files are changed; no implementation, fixture, or documentation changes are included.
ULP bounds
test/test.js1.0 * EPS * abs( expected )0test/test.native.js2.0 * EPS * abs( expected )00is the minimum boundNsuch thatisAlmostSameValue( y, expected[ i ], N ) === trueat every element of the fixture, and is thus the tightest bound possible. It was determined by computing the per-element ULP distance directly outside the test harness over the full 1000-point fixture: every fixture point is reproduced bit-for-bit by both implementations, so the maximum ULP distance is0for each. The previous relative tolerances (1.0 * EPSand2.0 * EPS) permitted a non-exact result, so the new bound is tighter than the tolerance it replaces rather than a loosening of the existing test.The excess kurtosis is evaluated as a short sequence of multiplications, additions, and a single division, and the JavaScript and C implementations perform those operations in the same order, which is why both agree exactly with the Julia reference across the fixture.
make test TESTS_FILTER=".*/stats/base/dists/beta/kurtosis/.*"was run twice at the final bound with identical results on both runs (1014 assertions in each of the two test files, 2028 in total, no failures and no skips), ruling out FMA/architecture-dependent flakiness on this platform. The native add-on was built locally (node-gyp rebuild) so thattest.native.jsactually executed rather than being skipped.make eslint-tests TESTS_FILTER=".*/stats/base/dists/beta/kurtosis/.*"is clean, as ismake lint-license-headers-filesfor the changed files.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
The resulting diff mirrors the already-merged migrations for the sibling distribution packages
stats/base/dists/beta/skewness,stats/base/dists/beta/variance, andstats/base/dists/beta/stdev, which share the same test structure and, in the first two cases, the same0ULP bound.Two environment notes, neither of which affected verification:
make install-node-modulesinitially failed withETARGETfores-object-atoms@^1.1.2. The local npm packument cache was stale and served a filtered view of the registry; afternpm cache clean --force, the install andmake initcompleted and the full toolchain was available for this PR.pre-commithook'slint-editorconfig-filesstep could not run, because it downloads theeditorconfig-checkerbinary from a GitHub release that this environment cannot reach. The changed files were instead checked manually against.editorconfig: LF line endings, tab indentation, no trailing whitespace, and a final newline.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code, running as an unattended scheduled task. It selected the package, studied previously migrated packages in the same family to match the established idiom, performed the migration, and determined the minimum passing ULP bound empirically over the full fixture set.
@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_018pww2eTE6dBtB2G1jEpVDr
Generated by Claude Code