Skip to content

test: migrate math/base/special/acoversinf to ULP-based testing - #13774

Merged
kgryte merged 6 commits into
stdlib-js:developfrom
ujjwalv01:test-acoversinf-ulp
Jul 31, 2026
Merged

kgryte merged 6 commits into
stdlib-js:developfrom
ujjwalv01:test-acoversinf-ulp

Conversation

@ujjwalv01

Copy link
Copy Markdown
Member

Resolves part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • Migrates the tests for @stdlib/math/base/special/acoversinf to use precise ULP-based bounds for floating-point comparisons rather than relative epsilon tolerances.
  • Replaces absolute differences and epsilon logic with @stdlib/number/float32/base/assert/is-almost-same-value across the JavaScript and C++ native add-on test suites.
  • Applies a strict empirical ULP maximum computed from the provided JSON fixtures (234 ULPs).

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.

No.

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.".

{{TODO: add disclosure if applicable}}


@stdlib-js/reviewers

@ujjwalv01
ujjwalv01 requested a review from a team July 30, 2026 08:35
@stdlib-bot stdlib-bot added Good First PR A pull request resolving a Good First Issue. Needs Review A pull request which needs code review. labels Jul 30, 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

stdlib-bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/acoversinf $\\color{green}169/169$
$\\color{green}+0.00\\%$
$\\color{green}5/5$
$\\color{green}+0.00\\%$
$\\color{green}2/2$
$\\color{green}+0.00\\%$
$\\color{green}169/169$
$\\color{green}+0.00\\%$

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

@ujjwalv01

Copy link
Copy Markdown
Member Author

When replacing the relative epsilon tolerance with exact ULP bounds for `@stdlib/math/base/special/acoversinf, I calculated the strict mathematical deviation across all the provided JSON test fixtures (data.json and small_positive.json).

I found that the maximum deviation between the computed float32 value and the theoretical expected value in the fixtures hits exactly 234 ULPs at its worst point.

If we look at the original test suite, the tolerance was previously defined as: tol = 230.0 * EPS * absf( e );

Because the original test already permitted a relative error of ~230 machine epsilons (due to the inherent floating-point precision loss of acoversinf), bounding the exact isAlmostSameValuef assertion strictly to 234 ULPs mathematically aligns with the original tolerance intent while providing a modern, exact empirical upper bound.

@kgryte kgryte added difficulty: 1 Low degree of difficulty. Should be straightforward to implement and/or resolve. Tests Pull requests specifically adding tests. review: 5 and removed Needs Review A pull request which needs code review. labels Jul 30, 2026
Comment thread lib/node_modules/@stdlib/math/base/special/acoversinf/test/test.js Outdated
Comment thread lib/node_modules/@stdlib/math/base/special/acoversinf/test/test.native.js Outdated

@kgryte kgryte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comments.

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. review: 3 and removed review: 5 labels Jul 30, 2026
@stdlib-bot stdlib-bot added the Math Issue or pull request specific to math functionality. label Jul 30, 2026
@ujjwalv01

Copy link
Copy Markdown
Member Author

Ah, good catch! I used 234 there by mistake because I globally applied the ULP bound from the first test block (which originally used 230.0 * EPS) to both test blocks during the migration. I completely missed that the small positive numbers block originally used a much tighter tolerance of just EPS * absf( e ).

I have just pushed a commit that decreases the ULP bound back down to 1 for the small positive numbers block in both test.js and test.native.js to match its original strictness. Thanks for catching that oversight!

@kgryte kgryte removed the Needs Changes Pull request which needs changes before being merged. label Jul 31, 2026
@kgryte
kgryte merged commit e932b6f into stdlib-js:develop Jul 31, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

difficulty: 1 Low degree of difficulty. Should be straightforward to implement and/or resolve. Good First PR A pull request resolving a Good First Issue. Math Issue or pull request specific to math functionality. review: 3 Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants