Skip to content

test: migrate constants/float32/ln-half to ULP-based assertions - #16192

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-constants-float32-ln-half
Draft

kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-constants-float32-ln-half

Conversation

@kgryte

@kgryte kgryte commented Oct 16, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the test suite for constants/float32/ln-half from a relative tolerance assertion to a ULP difference assertion.

The export equals lnf(0.5) test previously computed delta = absf( v - FLOAT32_LN_HALF ) and tol = EPS and asserted with t.ok( delta <= tol, ... ). It now delegates to @stdlib/number/float32/base/assert/is-almost-same-value:

tape( 'export equals `lnf(0.5)`', function test( t ) {
	var v = lnf( 0.5 );
	t.strictEqual( isAlmostSameValue( v, FLOAT32_LN_HALF, 0 ), true, 'returns expected value' );
	t.end();
});

Final ULP constant: 0.

File Call sites ULP bound
test/test.js 1 0

Notes on how the bound was measured:

  • The bound was tightened empirically, starting from n = 64 and stepping down (64, 32, 16, 8, 4, 2, 1, 0). Every probe passes, so 0 is the measured minimum and no smaller non-negative bound exists.
  • lnf( 0.5 ) returns -0.6931471824645996, which is bit-identical to the exported constant -0.6931471824645996; @stdlib/number/float32/base/ulp-difference reports a difference of exactly 0 ULP. The single-precision variant of the assertion is used here (matching the already-converted constants/float32/ln-two, constants/float32/pi-squared, and constants/float32/half-ln-two) so that the gap is measured in single-precision units.
  • The suite was run twice at the final bound to confirm determinism; all 4 assertions pass both times.
  • This package has no test.native.js, so there is no JS/C divergence to account for.
  • The two pre-existing exact assertions (typeof and the exact value check) are intentionally left unchanged, as exact comparisons remain correct there.
  • Only the one test file is modified; no source, documentation, or fixture changes.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

The bound is reproducible across architectures: the comparison is between two compile-time-fixed single-precision values and is not subject to FMA-contraction differences.

make eslint-tests TESTS_FILTER=".*/constants/float32/ln-half/.*" and make test TESTS_FILTER=".*/constants/float32/ln-half/.*" both pass. The changed file was additionally verified for tabs-only indentation, no new trailing whitespace, LF endings, and a final newline.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was authored by Claude Code. It studied the already-converted packages in the same family (notably constants/float32/ln-two and constants/float16/ln-half) 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_0145oPrciok5CLgLVy5bna7i


Generated by Claude Code

Migrate the test suite for `constants/float32/ln-half` from a relative
tolerance assertion to a ULP difference assertion.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0145oPrciok5CLgLVy5bna7i
@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Oct 16, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Hello! 👋

We've noticed that you've been opening a number of PRs addressing good first issues. Thank you for your interest and enthusiasm!

Now that you've made a few contributions, we suggest no longer working on good first issues. Instead, we encourage you to prioritize cleaning up any PRs which have yet to be merged and then proceed to work on more involved tasks.

Not only does this ensure that other new contributors can work on things and get ramped up on all things stdlib, it also ensures that you can spend your time on more challenging problems. 🚀

For ideas for future PRs, feel free to search the codebase for TODOs and FIXMEs and be sure to check out other open issues on the issue tracker. Cheers!

@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
constants/float32/ln-half $\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}0/0$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants