Skip to content

test: migrate math/base/special/factorial to ULP-based assertions - #14182

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-factorial
Aug 12, 2026
Merged

test: migrate math/base/special/factorial to ULP-based assertions#14182
kgryte merged 1 commit into
developfrom
kgryte/ulp-factorial

Conversation

@kgryte

@kgryte kgryte commented Aug 12, 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/factorial from relative tolerance testing to ULP difference testing, replacing the computed delta/tol comparisons with @stdlib/assert/is-almost-same-value.
  • removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires and the associated delta/tol local variables.
  • applies the same changes to both test/test.js and test/test.native.js.

The ULP bounds were tightened to the minimum value which still passes over the full fixture sets:

Fixture set Assertion Final ULP Measured minimum
integers.json (171 values) positive integers < 171 1 1 (fails at 0, worst case x = 33)
decimals.json (1003 values) decimal values 6 6 (fails at 5, worst case x = -26.71996007984032)

Note that the previous tolerances were EPS * abs( expected ) and 3.5 * EPS * abs( expected ), respectively, so the new bounds are of comparable tightness while being expressed in the natural floating-point accuracy unit.

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.

Verification notes:

  • test/test.js passes (2671 assertions). The suite was run twice at the final ULP values with identical results, in order to rule out FMA/architecture-dependent flakiness.
  • Tightness was confirmed by re-running the fixture sets at N-1: the integer fixtures fail at 0 ULP (13 cases) and the decimal fixtures fail at 5 ULP (1 case).
  • test/test.native.js reports no assertions in this environment because the native add-on was not built. To avoid assuming that the C implementation matches the JavaScript implementation, the C implementation (src/main.c plus its transitive C dependencies) was compiled standalone and evaluated against the same fixtures. It requires identical bounds (1 and 6) with the same worst-case inputs, so the same ULP values are used in both test files.

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 by Claude Code, running as an unattended scheduled task. The conversion mirrors the idiom established in previously merged migration commits, and the ULP bounds were determined empirically rather than guessed.


@stdlib-js/reviewers


Generated by Claude Code

Replace relative tolerance assertions with ULP-based assertions using
`@stdlib/assert/is-almost-same-value`.

The ULP bounds were empirically tightened to the minimum passing values
over the full fixture sets: 1 ULP for the integer fixtures and 6 ULP for
the decimal fixtures. Both the JavaScript and C implementations require
identical bounds.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG6eNsViEh6xK1Ms4x2tGr
@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 12, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/factorial $\\color{green}214/214$
$\\color{green}+100.00\\%$
$\\color{green}13/13$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}214/214$
$\\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 12, 2026
@kgryte
kgryte marked this pull request as ready for review August 12, 2026 04:55
@kgryte
kgryte requested a review from a team August 12, 2026 04:55
@kgryte
kgryte merged commit 7cbba5f into develop Aug 12, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-factorial branch August 12, 2026 04:55
@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 12, 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