test: migrate stats/base/dists/triangular/cdf to ULP-based assertions - #15112
Draft
kgryte wants to merge 1 commit into
Draft
test: migrate stats/base/dists/triangular/cdf to ULP-based assertions#15112kgryte wants to merge 1 commit into
stats/base/dists/triangular/cdf to ULP-based assertions#15112kgryte wants to merge 1 commit into
Conversation
Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QMdFi7UjR2HWqwVCypejPd
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/triangular/cdffrom 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.cdf.js,test/test.factory.js, andtest/test.native.js(three fixture blocks in each).@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires from all three test files, along with thedeltaandtolvariable declarations and the redundanty === expected[ i ]exact-match branch.Only test files are changed; no implementation, fixture, or documentation changes are included.
ULP bounds
b - a(test.cdf.js,test.factory.js,test.native.js)julia/small_range.json1.0 * EPS * abs( expected[ i ] )0b - a(test.cdf.js,test.factory.js,test.native.js)julia/medium_range.json1.0 * EPS * abs( expected[ i ] )0b - a(test.cdf.js,test.factory.js,test.native.js)julia/large_range.json1.0 * EPS * abs( expected[ i ] )00is the minimum integerNsuch thatisAlmostSameValue( y, expected[ i ], N )holds for every entry in each fixture, and, being the smallest representable bound, it cannot be tightened further. Starting from a high bound and tightening, the measured maximum ULP difference over the 3000 fixture values (1000 per range) is exactly0; both the main function and the function returned byfactoryreproduce all 3000 Julia reference values bit-for-bit. This was confirmed independently of the test harness by searching, for each fixture entry, for the smallestNsatisfyingisAlmostSameValue( y, expected[ i ], N ).The C implementation was measured the same way and also reproduces all 3000 reference values bit-for-bit, so
test.native.jsuses the same bound as the JavaScript tests. In addition to the in-harness measurement,src/main.cwas compiled together with its transitive C dependencies into a standalone program which was fed the fixture inputs as exact IEEE-754 bit patterns; the returned bit patterns matched the fixture expectations exactly, which additionally rules out any FMA-contraction difference on this platform.The native add-on was built locally (
make install-node-addons), sotest/test.native.jsexecutes rather than being skipped. The full suite was run twice at the final bound with identical results both times:9049assertions passing acrosstest.js(3),test.cdf.js(3012),test.factory.js(3022), andtest.native.js(3012); no failures and no skipped tests.make eslint-tests TESTS_FILTER=".*/stats/base/dists/triangular/cdf/.*"is clean.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 assertion matches the idiom used by the already-migrated sibling packages
stats/base/dists/triangular/logcdfandstats/base/dists/triangular/mgf, which apply the migration acrosstest.<name>.js,test.factory.js, andtest.native.jsover the same style of Julia fixtures.One environment note:
make install-node-modulesfails out of the box here because npm cannot resolvees-object-atoms@^1.1.2(a transitive dependency; the registry publishes only up to1.1.1). The install was completed by temporarily pinning that transitive dependency via an npmoverridesentry, which was reverted before committing and is not part of this diff. The pre-commiteditorconfighook could not run either, since it downloads its checker binary from GitHub and network access to that repository is not available in this environment; the three changed files were instead verified manually against.editorconfig(LF endings, UTF-8, tab indentation, no trailing whitespace, final newline present).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 converted packages in the same family to match the established idiom, performed the conversion, 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_01QMdFi7UjR2HWqwVCypejPd
Generated by Claude Code