Skip to content

test: migrate math/base/special/ahavercos to ULP-based assertions - #14011

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-ahavercos
Aug 7, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-ahavercos

Conversation

@kgryte

@kgryte kgryte commented Aug 7, 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/ahavercos from relative tolerance testing (delta = abs( y - expected[i] ), tol = EPS * abs( expected[i] ), t.ok( delta <= tol, ... )) to ULP difference testing using @stdlib/assert/is-almost-same-value.
  • updates both test/test.js and test/test.native.js, which mirror one another.
  • removes the now unused @stdlib/math/base/special/abs import from both test files (@stdlib/constants/float64/eps is retained, as EPS is still used by the out-of-domain test cases).

The ULP bounds were tightened to the measured minimum which passes over the full fixture set, for both the JavaScript and the C implementations:

Fixture file Test case ULP bound Measured maximum ULP difference
fixtures/julia/data.json the function computes the inverse half-value versed cosine 1 1 (JS and native)
fixtures/julia/small_positive.json the function computes the inverse half-value versed cosine (small positive numbers) 0 0 (JS and native)

Notes on how the bounds were determined:

  • Each bound is the minimum non-negative integer for which every fixture value passes. Lowering the data.json bound from 1 to 0 fails for 446 of 2003 fixture values, so 1 is tight. All 2003 small_positive.json values are bit-for-bit exact, hence a bound of 0.
  • The JavaScript and C implementations agree exactly on both fixture sets, so test.js and test.native.js use identical bounds.
  • The native add-on was compiled locally, so test/test.native.js was exercised against the actual C implementation rather than skipped. Both test files were run twice at the final bounds, with identical results (24009 assertions passing per file, per run).

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.

  • Only the two test files are modified; no source, documentation, benchmark, or fixture files are touched.
  • Verified with make test TESTS_FILTER=".*/math/base/special/ahavercos/.*" and by running test/test.native.js directly against the compiled add-on. Linting is clean via ESLint using etc/eslint/.eslintrc.tests.js.

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, running as an unattended scheduled task. The test migration follows the idiom established by previously merged conversions, and the ULP bounds were measured empirically against both the JavaScript and compiled C implementations rather than guessed.


@stdlib-js/reviewers


Generated by Claude Code

@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 7, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

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