Repository navigation
test: migrate stats/base/dists/planck/skewness to ULP-based assertions - #14797
Merged
Merged
Conversation
Replaces relative tolerance assertions with ULP difference assertions using `@stdlib/assert/is-almost-same-value`. The ULP bound was tightened to the measured minimum of 1 ULP over the full Python fixture set. Ref: #11352
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
kgryte
marked this pull request as ready for review
August 30, 2026 02:27
5 of 7 tasks
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/planck/skewnessfrom relative tolerance testing to ULP difference testing, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.Changes are confined to
test/test.jsandtest/test.native.js. In each, the fixture loop'sdelta/tolcomputation and they === expected[i]branch are replaced with a singleisAlmostSameValueassertion,@stdlib/assert/is-almost-same-valueis added to the module requires, and the now-unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires are removed. No other test cases, loop bounds, or fixtures are touched.ULP bound:
1in bothtest/test.jsandtest/test.native.js.This is the measured minimum, not a guess. The JS and native implementations were each evaluated against all 1000 Python fixture cases, and the per-case ULP distance between the returned and expected values was computed directly via
@stdlib/number/float64/base/ulp-difference. The resulting distribution was identical for both implementations: 891 cases at0ULP and 109 cases at exactly1ULP, so the maximum over the full fixture set is1. The worst case islambda = 7.28771354747294, where the returned38.265183277421535differs from the expected38.26518327742153by one representable step. Lowering the bound to0fails 109 of the 1000 cases, so1is the tightest integer bound that holds.The C and JavaScript implementations return bit-identical results across all 1000 fixture cases, so a single bound is correct for both files.
The previous bound was
1.0 * EPSin both files (guarded by an exact-equality fast path). A1ULP bound is at least as tight everywhere, and strictly tighter for values just above a power of two, where1.0 * EPS * |expected|spans nearly two representable steps.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
Verification performed:
make test TESTS_FILTER=".*/stats/base/dists/planck/skewness/.*"passes: 1005/1005 intest/test.jsand 1005/1005 intest/test.native.js.node-gyp rebuild) so thattest/test.native.jsactually exercised the C implementation rather than being skipped; it passes at the same1ULP bound. The build artifacts were removed before committing.0produces 109 failures, matching the measured ULP histogram exactly.etc/eslint/.eslintrc.tests.js, and passeditorconfig-checkerunder bothetc/editorconfig-checker/.editorconfig_checker.jsonand.editorconfig_checker.markdown.json.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 automated task. The conversion mirrors the idiom established by previously merged
stats/base/dists/*conversions (for exampleplanck/stdev,rayleigh/variance,negative-binomial/stdev), and the ULP bound was determined empirically by measuring the per-case ULP distance across the full fixture set for both the JavaScript and C implementations, rather than by trial and error.@stdlib-js/reviewers
Generated by Claude Code