Repository navigation
test: migrate constants/float32/half-ln-two to ULP-based assertions - #16071
Merged
Merged
Conversation
Migrates the `constants/float32/half-ln-two` test suite from relative tolerance testing to ULP difference testing, mirroring the already-merged `constants/float32/ln-ten` migration. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U6N75xEUk9H2udTb75gi8F
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 12, 2026 00:26
This was referenced Oct 13, 2026
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/float32/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/number/float32/base/assert/is-almost-same-valueimport and removes the now-unused@stdlib/math/base/special/absfand@stdlib/constants/float32/epsimports.delta/tolcomputations (and the correspondingvar delta;/var tol;declarations) from theexport equals 0.5*lnf(2)test case.t.ok( delta <= tol, ... )witht.strictEqual( isAlmostSameValue( v, FLOAT32_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/ln-tenmigration (3560347 / #16059). That package's test file is structurally identical to this one apart from the constant being checked, so it serves as direct prior art for every change here — including the use of the single-precision@stdlib/number/float32/base/assert/is-almost-same-valuerather than the double-precision@stdlib/assert/is-almost-same-value, since the value under test is a single-precision constant.ULP bound
export equals 0.5*lnf(2)float64ToFloat32( 0.5 * lnf( 2.0 ) )andFLOAT32_HALF_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/ln-ten, and is substantially tighter than the relative tolerance it replaces (EPS * FLOAT32_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/float32/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.maxULP === 0and accepted atmaxULP === 1.make eslint-tests TESTS_FILTER=".*/constants/float32/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 ASCII/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/ln-tenmigration 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