Skip to content

test: migrate math/base/special/sincosdf to ULP-based assertions - #14521

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-sincosdf
Aug 22, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-sincosdf

Conversation

@kgryte

@kgryte kgryte commented Aug 22, 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/sincosdf from relative tolerance testing to ULP difference testing, per [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • replaces the delta/tol comparisons (and their if ( y === expected ) { ... } else { ... } wrappers) with isAlmostSameValue( actual, expected, N ) assertions, using @stdlib/number/float32/base/assert/is-almost-same-value, as the package operates on single-precision values.
  • removes the now-unused @stdlib/constants/float32/eps and @stdlib/math/base/special/absf imports, along with the delta and tol local variables.
  • updates test/test.main.js, test/test.assign.js, and test/test.native.js. test/test.js is a smoke test which contains no tolerance-based assertions and is thus left unchanged.

The ULP bounds were measured against the full fixture set (6 fixture files x 4000 values, for both the sine and cosine outputs) and set to the minimum value which passes:

Fixture sine cosine
medium_negative 1 1
medium_positive 1 1
large_negative 1 0
large_positive 1 0
huge_negative 1 0
huge_positive 1 0

Each bound is tight. For every bound of 1, at least one fixture value differs from the expected value by exactly 1 ULP (e.g., 645 of 4000 sine values in medium_negative), so 0 fails. For every bound of 0, all 4000 values match exactly.

The measured maxima are identical for the JavaScript implementation (lib/main.js), the assign implementation (lib/assign.js), and the C implementation (lib/native.js), so the same bounds are used in all three test files. The native addon was compiled locally in order to confirm this.

The full package test suite (make test TESTS_FILTER=".*/math/base/special/sincosdf/.*") was run twice at the final bounds, with identical results both times (48008 / 72024 / 6 / 48008 assertions passing, 0 failing).

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 test files are changed; no source, documentation, or fixture files are modified.

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 edits were applied mechanically, the ULP bounds were derived from measured per-fixture ULP-difference histograms rather than guessed, and the prior art in already-migrated packages (e.g., math/base/special/sici, math/base/special/logitf) was used to match the established idiom. Opened as a draft for human review.


@stdlib-js/reviewers


Generated by Claude Code

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/sincosdf $\\color{green}252/252$
$\\color{green}+100.00\\%$
$\\color{green}7/7$
$\\color{green}+100.00\\%$
$\\color{green}3/3$
$\\color{green}+100.00\\%$
$\\color{green}252/252$
$\\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 22, 2026
@kgryte
kgryte marked this pull request as ready for review August 22, 2026 07:49
@kgryte
kgryte requested a review from a team August 22, 2026 07:49
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 22, 2026
@kgryte
kgryte merged commit 10c2645 into develop Aug 22, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-sincosdf branch August 22, 2026 07:50
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 22, 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