Skip to content

test: migrate math/base/special/expm1rel to ULP-based assertions - #13982

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-expm1rel
Aug 6, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-expm1rel

Conversation

@kgryte

@kgryte kgryte commented Aug 6, 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 math/base/special/expm1rel from relative tolerance (EPS-scaled) assertions to ULP-based assertions using @stdlib/assert/is-almost-same-value, matching the idiom used by previously converted double-precision packages (e.g., hypot, ellipk, expit, cphase).
  • updates both test/test.js and test/test.native.js, removing the abs import and the delta/tol computations in favor of t.strictEqual( isAlmostSameValue( v, expected[ i ], N ), true, 'returns expected value' );. The EPS import is retained in both files, as it is still used by the "returns 1.0 near 0.0" test.

Final ULP constants (per fixture set, identical in test/test.js and test/test.native.js):

Fixture set ULP bound Worst case
medium_negative.json 0 exact for all 1000 points
medium_positive.json 2 x = 87.55771771771771, y = 1.2121021459952258e+36, expected 1.2121021459952261e+36
small_negative.json 3 x = -0.22922922922922928, y = 0.8936633379449439, expected 0.8936633379449436
small_positive.json 3 x = 0.4644644644644645, y = 1.2727816274388977, expected 1.272781627438897
tiny.json 0 exact for all 1000 points

The previous tolerance was a uniform 3.0 * EPS * abs( expected[ i ] ) for every fixture set.

The bounds were tightened empirically rather than guessed. Starting from a high bound and lowering it, the measured maximum ULP distance was computed for every one of the 5000 fixture points, and the values above are the minima: lowering the 2 to 1 and the 3s to 2 produces 21 failing assertions, while at the stated bounds all 5008 assertions pass.

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?

The medium_negative and tiny fixture sets are reproduced exactly (0 ULP). Reviewers may prefer a floor of 1 there for robustness against future implementation changes; 0 is used here as it is the measured minimum, consistent with the guidance in #11352 and with the ~300 existing isAlmostSameValue( ..., 0 ) assertions already in the tree.

Other

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

  • Only the two test files are modified; no implementation, fixture, or documentation changes.
  • The suite was run twice at the final bounds to confirm the result is deterministic (no FMA/architecture-dependent flakiness).
  • The native add-on could not be built in the authoring environment, so test/test.native.js skipped locally. To avoid guessing its bounds, the C implementation (src/main.c, plus its expm1/abs/is_nan dependencies) was compiled standalone with gcc -O2 and evaluated over the same fixture points: the C implementation reproduces the JavaScript results bit-for-bit, giving identical per-set bounds of 0, 2, 3, 3, 0. The two test files therefore use the same constants. Confirmation from CI (where the add-on is built) would be welcome.
  • ESLint (etc/eslint/.eslintrc.tests.js) reports no errors or warnings for either file; the pre-commit JavaScript test lint and filename lint hooks both passed.

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 as part of an automated, unattended run: it selected the package, studied the idiom used in previously merged conversions, applied the test edits, and measured the minimum passing ULP bounds by running the suite.


@stdlib-js/reviewers


Generated by Claude Code

Migrates the tests for `math/base/special/expm1rel` from relative
tolerance (`EPS`-scaled) assertions to ULP-based assertions using
`@stdlib/assert/is-almost-same-value`.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VXgZDZZDJZ92eUM4AwD1Cu

---
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: passed
  - 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
---
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Good First PR A pull request resolving a Good First Issue. labels Aug 6, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/expm1rel $\\color{green}198/198$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}198/198$
$\\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 Aug 6, 2026
@kgryte
kgryte marked this pull request as ready for review August 6, 2026 16:27
@kgryte
kgryte requested a review from a team August 6, 2026 16:27
@kgryte
kgryte merged commit 6369e3b into develop Aug 6, 2026
68 checks passed
@kgryte
kgryte deleted the kgryte/ulp-expm1rel branch August 6, 2026 16:27
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Aug 6, 2026
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. Math Issue or pull request specific to math functionality. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants