test: migrate stats/base/dists/gamma/pdf to ULP-based assertions - #14206
Merged
Conversation
Replace relative EPS-based tolerance checks with ULP-based assertions using `@stdlib/assert/is-almost-same-value`. ULP bounds were tightened to the measured minimum over the full fixture sets. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TGwbG5ir9JJQ9XefVFP4rT --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: skipped - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
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/gamma/pdffrom relative tolerance testing (delta = abs( y - expected[i] ),tol = 170.0 * EPS * abs( expected[i] ),t.ok( delta <= tol, ... )) to ULP difference testing using@stdlib/assert/is-almost-same-value.test/test.pdf.js,test/test.factory.js, andtest/test.native.js, which mirror one another.test/test.jsonly asserts the shape of the exported API and contains no tolerance comparisons, so it is left untouched.@stdlib/math/base/special/absand@stdlib/constants/float64/epsimports from the three updated test files, asabsandEPSare not used anywhere else in those files.The ULP bounds were tightened to the measured minimum which passes over the full fixture set, for both the JavaScript and the C implementations:
fixtures/julia/both_large.jsonxgiven largealphaandbeta170.0 * EPS275fixtures/julia/large_shape.jsonxgiven large shape parameteralpha140.0 * EPS168fixtures/julia/large_rate.jsonxgiven large rate parameterbeta120.0 * EPS208Notes on how the bounds were determined:
isAlmostSameValueper fixture value and taking the maximum over each 1000-value fixture set. In each set exactly one value attains the maximum, so none of the three bounds can be lowered.274,167,207) was explicitly checked and fails with exactly three failing assertions, one per fixture set, confirming that the bounds are tight.test.pdf.js,test.factory.js, andtest.native.jsuse identical bounds. The number of bit-for-bit exact values against the Julia reference is likewise identical for both implementations (10 of 1000 forboth_large, 18 of 1000 forlarge_shape, 38 of 1000 forlarge_rate).ln(gamma)-style intermediates and the accumulated error relative to the Julia reference is correspondingly larger. The bounds are consistent in magnitude with the relative tolerances they replace (ak * EPSrelative tolerance corresponds to roughlykto2kULP, depending on where the value sits within its binade).test/test.native.jswas exercised against the actual C implementation rather than skipped.test.js, 3026 fortest.pdf.js, 3030 fortest.factory.js, and 3026 fortest.native.js, all passing.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
make lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/gamma/pdf/.*", which usesetc/eslint/.eslintrc.tests.js.pre-commithook's EditorConfig check could not run in this session, as it downloads theeditorconfig-checkerbinary from GitHub releases and that request is blocked here. The commit was therefore made withSKIP_LINT_EDITORCONFIG=1; every other pre-commit check (JavaScript test linting, filename linting, license headers, commit message linting) ran and passed. The three modified files were instead checked manually against.editorconfig: LF line endings, UTF-8, 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 authored by Claude Code, running as an unattended scheduled task. The test migration follows the idiom established by previously merged conversions, and the ULP bounds were measured empirically against both the JavaScript and compiled C implementations rather than guessed.
@stdlib-js/reviewers
Generated by Claude Code