Repository navigation
test: migrate constants/float64/ln-two to ULP-based assertions - #16107
Merged
Merged
Conversation
Migrate the `export equals ln(2)` test from a computed relative tolerance assertion to a ULP difference assertion using `@stdlib/assert/is-almost-same-value`. The ULP bound was tightened empirically to its measured minimum of `0`, as `ln( 2.0 )` is bit-identical to the exported constant. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtZG3ucwuUhUZ2vBb33zNr
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
Signed-off-by: Athan <kgryte@gmail.com>
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:
constants/float64/ln-twofrom a relative tolerance assertion to a ULP difference assertion.The
export equals ln(2)test previously computeddelta = abs( v - LN2 )andtol = EPS * LN2and asserted witht.ok( delta <= tol, ... ). It now delegates to@stdlib/assert/is-almost-same-value:Final ULP constant:
0.test/test.jsNotes on how the bound was measured:
n = 64and stepping down (64, 32, 16, 8, 4, 2, 1, 0). Every probe passes, so0is the measured minimum and no smaller non-negative bound exists.ln( 2.0 )returns0.6931471805599453, which is bit-identical to the exported constant0.6931471805599453;@stdlib/number/float64/base/ulp-differencereports a difference of exactly0ULP.constants/float64/ln-two-pi.4assertions pass both times.test.native.js, so there is no JS/C divergence to account for.typeofand the exact0.6931471805599453value check) are intentionally left unchanged, as exact comparisons remain correct there.@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires are removed.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 bound is reproducible across architectures: the comparison is between two compile-time-fixed double-precision values and is not subject to FMA-contraction differences.
Note that the local
make lint-editorconfigcheck could not run in this environment (theeditorconfig-checkerbinary download is network-blocked), so the changed file was verified manually for tabs-only indentation, no trailing whitespace, LF endings, and a final newline.make eslint-tests TESTS_FILTER=".*/constants/float64/ln-two/.*"andmake test TESTS_FILTER=".*/constants/float64/ln-two/.*"both pass.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code. It studied the already-converted packages in the same family (notably
constants/float64/ln-two-piandconstants/float32/half-ln-two) to match the established idiom, then measured the minimum ULP bound empirically and verified determinism as described above.@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01DtZG3ucwuUhUZ2vBb33zNr
Generated by Claude Code