Skip to content

test: migrate constants/float16/ln-half to ULP-based assertions - #16173

Merged
kgryte merged 1 commit into
developfrom
claude/great-brahmagupta-mlw59e
Oct 15, 2026
Merged

kgryte merged 1 commit into
developfrom
claude/great-brahmagupta-mlw59e

Conversation

@kgryte

@kgryte kgryte commented Oct 15, 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 of @stdlib/constants/float16/ln-half from relative tolerance testing to ULP difference testing.
  • replaces the absf( v - FLOAT16_LN_HALF ) <= EPS tolerance comparison with isAlmostSameValue( v, FLOAT16_LN_HALF, 0 ), using @stdlib/number/float16/base/assert/is-almost-same-value (the half-precision assertion utility, matching the idiom already used by sibling packages such as constants/float16/ln-ten and constants/float16/half-ln-two).
  • rounds the computed lnf(0.5) value to half-precision via @stdlib/number/float64/base/to-float16 before comparison, so that the ULP difference is measured in half-precision units.
  • removes the now unused @stdlib/math/base/special/absf and @stdlib/constants/float16/eps requires.

Final ULP constant: 0. Starting from a high bound (64) and tightening (64 → 16 → 4 → 1 → 0), the measured maximum ULP difference between float64ToFloat16( lnf( 0.5 ) ) and the exported constant is 0 — both are the bit-identical half-precision value -0.693359375 — so 0 is the minimum required ULP value. The package test suite was run twice at the final bound and passed deterministically both times (4 passing, 0 failing).

Only test/test.js is modified; there is no test/test.native.js for this package.

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.

JavaScript linting of the changed file with etc/eslint/.eslintrc.tests.js is clean. Note that make lint-javascript lints the full src tree and currently reports a pre-existing, unrelated error in etc/typedoc/theme/assets/js/theme.js; that file is untouched by this pull request. The changed file was additionally verified against .editorconfig (LF line endings, UTF-8, tab indentation, no trailing whitespace, 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 written primarily by Claude Code, which located the package, mirrored the conversion idiom from already-migrated sibling packages, measured the minimum ULP bound, and ran the tests and linters.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vc6LdYTvcSnCUo61MorWP6


Generated by Claude Code

Migrate the test suite from relative tolerance testing to ULP difference
testing, per the idiom established by sibling packages such as
`constants/float16/ln-ten` and `constants/float16/half-ln-two`.

The computed `lnf(0.5)` value is rounded to half-precision via
`@stdlib/number/float64/base/to-float16` so that the ULP difference is
measured in half-precision units. The measured minimum required ULP
value is 0 (the values are bit-identical).

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

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

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

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Oct 15, 2026
@kgryte
kgryte marked this pull request as ready for review October 15, 2026 19:54
@kgryte
kgryte requested a review from a team October 15, 2026 19:54
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Oct 15, 2026
@kgryte
kgryte merged commit cd798a3 into develop Oct 15, 2026
66 checks passed
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Oct 15, 2026
@kgryte
kgryte deleted the claude/great-brahmagupta-mlw59e branch October 15, 2026 19:55
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. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants