Repository navigation
test: migrate stats/base/dists/logistic/variance to ULP-based assertions - #14484
Merged
Merged
Conversation
…tions Replaces the computed EPS-scaled relative tolerance comparisons in both the JavaScript and native tests with `isAlmostSameValue` assertions. Over the full 100-value Julia fixture set, the maximum ULP difference is 3 for both the JavaScript and native implementations, so the tightest passing bound is 3 ULP. Ref: #11352 Claude-Session: https://claude.ai/code/session_01Q6vFzKDfHmLxXqHG2jScRi
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.
Ref #11352.
Description
This pull request:
stats/base/dists/logistic/variancefrom computed floating-point tolerances to ULP-based assertions, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.delta/tol(2.0 * EPS * abs( expected[i] )) comparison intest/test.jswithisAlmostSameValue( y, expected[ i ], 3 ).delta/tolcomparison intest/test.native.jswithisAlmostSameValue( y, expected[ i ], 3 ).@stdlib/assert/is-almost-same-valuerequire and drops the now unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires.Final ULP bound:
3in bothtest/test.jsandtest/test.native.js.Measured minimum: starting from a high bound and tightening,
3is the minimum integer bound which passes over the full fixture set. Sweeping the bound over the 100 Julia fixture values gives, for both test files:test/test.jstest/test.native.js0123The maximum observed ULP difference is
3for both the JavaScript and the native implementation (worst case atmu = -3.790154994337721,s = 3.0019267654139057). The native add-on was built locally so thattest/test.native.jsactually executed rather than being skipped. The full suite (110 assertions intest/test.js, 111 intest/test.native.js) was run twice at the final bound with identical results, so no FMA/arch-related nondeterminism was observed on this platform (Linux x86-64, gcc).That the two implementations agree exactly is expected: both evaluate
( s*s ) * PI_SQUARED / 3.0, which offers no multiply-add for a compiler to contract.Only the two test files are modified; no source, documentation, benchmark, or fixture files are touched.
Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
3reflects the accuracy of the Julia reference values relative to the double-precision result ofs^2 * pi^2 / 3, not an implementation deficiency. If reviewers would prefer a round number for readability over the measured minimum,4would leave a single ULP of headroom.Other
eslint --config etc/eslint/.eslintrc.tests.jsover both files, andgit statusconfirms only the two test files changed.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code, which selected the package, mirrored the conversion idiom used in previously converted packages, measured the ULP bound against the fixture set, and verified tests and linting.
@stdlib-js/reviewers
Generated by Claude Code