Repository navigation
test: migrate constants/float64/half-ln-two to ULP-based assertions - #16098
Merged
Merged
Conversation
Replace the relative tolerance assertion in the `export equals 0.5*ln(2)` test case with an ULP difference assertion using `@stdlib/assert/is-almost-same-value`. The `delta`/`tol` computations and the now-unused `@stdlib/math/base/special/abs` and `@stdlib/constants/float64/eps` imports are removed. `0.5 * ln( 2.0 )` is bit-identical to the exported constant, so the measured ULP difference is 0, which is also the tightest possible bound. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017CV9AEfa7wkGtWEebxsa3M --- 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: na - 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 13, 2026 10:31
5 of 7 tasks
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/half-ln-twotest suite from relative tolerance testing to ULP difference testing, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.Specifically, this pull request:
@stdlib/assert/is-almost-same-valueimport and removes the now-unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsimports.delta/tolcomputations (and the correspondingvar delta;/var tol;declarations) from theexport equals 0.5*ln(2)test case.t.ok( delta <= tol, ... )witht.strictEqual( isAlmostSameValue( v, HALF_LN2, 0 ), true, 'returns expected value' );.Only
test/test.jsis modified; the package has notest/test.native.js. No other test cases were touched, and the existing exact comparisons (t.strictEqualon thetypeofcheck and on the literal constant value) were left as-is.The conversion mirrors, line for line, the already-merged
constants/float32/half-ln-twomigration (e08b3f7 / #16071), which is the single-precision counterpart of this exact constant and therefore serves as direct prior art for every change here. The one deliberate difference is the import: because the value under test is a double-precision constant, this pull request uses the double-precision@stdlib/assert/is-almost-same-valueprescribed by #11352, rather than the single-precision@stdlib/number/float32/base/assert/is-almost-same-valueused by the float32 package. This also matches the already-mergedconstants/float64/ln-two-pimigration (#15855).ULP bound
export equals 0.5*ln(2)0.5 * ln( 2.0 )andHALF_LN2are bit-identical, so the measured ULP difference is0, which is also the floor (isAlmostSameValuewithmaxULP === 0reduces toisSameValue). The bound therefore cannot be tightened further. This matches the0bound accepted for the corresponding test case inconstants/float32/half-ln-two, and is tighter than the relative tolerance it replaces (EPS * HALF_LN2, i.e. 1 ULP).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 test TESTS_FILTER=".*/constants/float64/half-ln-two/.*"passes 4/4. The suite was run three times at the final bound with identical results, confirming determinism (no FMA/arch-dependent variation in this environment). The test suite uses no PRNG, so the fixture values are fixed by construction.to-words/from-words) is rejected atmaxULP === 0and accepted atmaxULP === 1.make eslint-tests TESTS_FILTER=".*/constants/float64/half-ln-two/.*"passes cleanly, as doesmake lint-license-headers-filesfor the changed file.lint-editorconfig-filestarget was not run in this environment, as it downloads theeditorconfig-checkerbinary from a host that was not reachable from the sandbox. The file was instead verified programmatically against.editorconfig: LF line endings, valid UTF-8, tab indentation (no space-indented lines), no trailing whitespace, and a single 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. It selected the package at random from the remaining unconverted candidates, studied the already-merged
constants/float32/half-ln-twoandconstants/float64/ln-two-pimigrations as prior art, performed the test conversion, and determined the minimum ULP bound empirically by measuring the observed ULP difference and confirming that the bound is both minimal and the hard floor.@stdlib-js/reviewers
Generated by Claude Code