Skip to content

test: migrate math/base/special/sincosd to ULP-based assertions - #13992

Open
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-sincosd
Open

test: migrate math/base/special/sincosd to ULP-based assertions#13992
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-sincosd

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/sincosd 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., expit, ellipk, factorialln, falling-factorial).
  • updates test/test.main.js, test/test.assign.js, and test/test.native.js, removing the EPS/abs imports and the delta/tol computations in favor of t.strictEqual( isAlmostSameValue( y[ 0 ], sine[ i ], N ), true, 'returns expected value' );.

Final ULP constants:

Fixture set sine cosine
medium_negative 1 2
medium_positive 1 2
large_negative 1 1
large_positive 1 1
huge_negative 1 1
huge_positive 1 1

The same constants are used in all three test files.

The bounds were tightened empirically rather than guessed. Starting from a high bound and lowering it, the measured maximum ULP distance over the full fixture set (6 fixture files × 4000 points = 24000 points, each contributing a sine and a cosine assertion) is:

  • 1 ULP for sine across every fixture set.
  • 2 ULP for cosine on the two medium fixture sets, and 1 ULP elsewhere.

These are minimal:

  • Lowering sine from 1 to 0 produces 8260 failing assertions in test/test.main.js.
  • Lowering the medium cosine bound from 2 to 1 produces 2 failing assertions.
  • Lowering the large/huge cosine bound from 1 to 0 produces 3472 failing assertions.

At the final bounds, test/test.main.js passes all 48008 assertions and test/test.assign.js passes all 84024 assertions.

Note that the previous relative tolerances already encoded this same split: the medium fixture sets used tol = 1.01 * EPS * abs( cosine[i] ) for the cosine while every other assertion used tol = EPS * abs( ... ). The measured ULP bounds reproduce that structure exactly.

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?

Yes — one:

  • The native add-on could not be built in the environment used to author this PR (node-gyp was unavailable), so test/test.native.js was skipped rather than executed, and its ULP constants mirror the measured JavaScript bounds rather than being independently measured against the C implementation. Please confirm the native tests pass at these bounds in CI. If the C implementation is fractionally less accurate at any point, the corresponding constant in test/test.native.js may need to be raised.

Other

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

  • Only the three test files are modified; no implementation, fixture, or documentation changes.
  • test/test.js contains no tolerance-based assertions (it only checks the exports), so it is unchanged.
  • The suites were run twice at the final bounds to confirm the result is deterministic (no FMA/architecture-dependent flakiness).
  • ESLint (etc/eslint/.eslintrc.tests.js) is clean on all four 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 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

@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 23:18
@kgryte
kgryte requested a review from a team August 6, 2026 23:18
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. 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

Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants