Repository navigation
test: migrate stats/base/dists/triangular/logpdf to ULP-based assertions - #16007
Merged
Merged
Conversation
…tions Replace the computed relative-tolerance comparisons in the fixture loops with `@stdlib/assert/is-almost-same-value`, using the minimum ULP bound which still passes over the full fixture set. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C1iYP8dmC8M4qwafggaiHe --- 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. |
kgryte
marked this pull request as ready for review
October 11, 2026 12:40
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/triangular/logpdffrom relative tolerance testing to ULP difference testing.if ( y === expected[i] ) { ... } else { delta/tol ... }branches and thet.ok( delta <= tol, ... )assertions witht.strictEqual( isAlmostSameValue( y, expected[ i ], N ), true, 'returns expected value' );.@stdlib/assert/is-almost-same-valueimport and removes the now unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsimports. The@stdlib/math/base/special/lnimport is retained, as it is still used by thex = ctest.Final ULP constants
Each of the three fixture sets (
small_range.json,medium_range.json,large_range.json, 1000 values each) is asserted with its own bound. Starting from a high bound and tightening, the measured minimum per fixture set and per test file is:test/test.logpdf.js555283test/test.factory.js557683test/test.native.js397683Every one of these nine bounds is the measured minimum: decrementing any one of them by
1causes exactly one assertion in that fixture set to fail. The bounds are comparatively large because the fixture values are logarithms close to zero (the worst cases sit near±0.007), so the pre-existing40/60/50 * EPSrelative tolerances already corresponded to tens of ULP at that magnitude.The bounds differ slightly between the JS main export, the factory-created function, and the C implementation. This mirrors other migrated distribution packages where the JS and C results differ for the same inputs (e.g.
stats/base/dists/betaprime/logcdf,stats/base/dists/f/quantile,stats/base/dists/gamma/quantile), per the FAQ.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 locally:
make test TESTS_FILTER=".*/stats/base/dists/triangular/logpdf/.*"→ 9067 passing, 0 failing, run twice at the final bounds with identical per-file counts, to confirm determinism.test/test.native.jsexecuted rather than being skipped; its bounds were therefore measured, not assumed. The build artifacts were removed before committing.eslint -c etc/eslint/.eslintrc.tests.json the three changed files → clean.The idiom follows the already-converted sibling package
stats/base/dists/triangular/logcdf, which has the identical test-file layout.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code. The migration mirrors the idiom established in the sibling package
stats/base/dists/triangular/logcdf, and every ULP bound was measured empirically over the full fixture set (and shown to be minimal) rather than assumed.@stdlib-js/reviewers