Skip to content

test: migrate constants/float16/ln-sqrt-two-pi to ULP-based assertions - #16215

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-constants-float16-ln-sqrt-two-pi
Draft

kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-constants-float16-ln-sqrt-two-pi

Conversation

@kgryte

@kgryte kgryte commented Oct 17, 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 tests for constants/float16/ln-sqrt-two-pi from relative tolerance testing to ULP difference testing, per [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • replaces the computed delta/tol comparison (absf( v - FLOAT16_LN_SQRT_TWO_PI ) <= EPS * FLOAT16_LN_SQRT_TWO_PI) with t.strictEqual( isAlmostSameValue( v, FLOAT16_LN_SQRT_TWO_PI, 0 ), true, 'returns expected value' ).
  • adds a @stdlib/number/float16/base/assert/is-almost-same-value require and drops the now unused @stdlib/math/base/special/absf and @stdlib/constants/float16/eps requires.
  • rounds the computed value to half-precision via @stdlib/number/float64/base/to-float16 before comparison, matching the idiom already used by the converted sibling packages (constants/float16/ln-ten, constants/float16/ln-half, constants/float16/half-ln-two, and constants/float16/pi-squared).

ULP bound: 0.

The bound was tightened empirically: starting from a high value and lowering it to the minimum integer which still passes, float64ToFloat16( lnf( sqrtf( FLOAT16_TWO_PI ) ) ) is bit-for-bit equal to the exported constant (measured half-precision ULP difference of 0), so 0 is the minimum required value. The suite was run twice at the final bound to confirm determinism. This also matches the bound used by the already-converted constants/float16 sibling packages.

Only test/test.js is changed; no source, documentation, or benchmark files are touched.

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.

  • make test TESTS_FILTER=".*/constants/float16/ln-sqrt-two-pi/.*" passes (4/4 assertions), run twice with identical results.
  • make lint-javascript-tests TESTS_FILTER=".*/constants/float16/ln-sqrt-two-pi/.*" is clean.

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 written primarily by Claude Code, which located the candidate package, mirrored the conversion idiom from the already-converted constants/float16 sibling packages, measured the minimum required ULP bound, and ran the tests and linter.


@stdlib-js/reviewers


Generated by Claude Code

Replace the relative tolerance assertion with a ULP difference
assertion using `number/float16/base/assert/is-almost-same-value`.

Resolves a part of #11352.

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
constants/float16/ln-sqrt-two-pi $\\color{green}51/51$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}0/0$
$\\color{green}+100.00\\%$
$\\color{green}51/51$
$\\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.

3 participants