Skip to content

test: migrate math/base/special/csignumf to ULP-based assertions - #14354

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-csignumf
Aug 17, 2026
Merged

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

Conversation

@kgryte

@kgryte kgryte commented Aug 17, 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/csignumf from relative tolerance testing to ULP difference testing.
  • replaces the EPS-scaled tolerance comparisons in test/test.js and test/test.native.js with isAlmostSameValue assertions from @stdlib/number/float32/base/assert/is-almost-same-value (the single-precision variant, as csignumf returns a Complex64).
  • removes the now unused @stdlib/constants/float32/eps and @stdlib/math/base/special/absf requires, along with the associated delta and tol variables and the exact-versus-tolerance if...else branch.

The final ULP bound is 1 ULP, applied to both the real and imaginary component assertions in test/test.js and test/test.native.js.

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.

Notes on how the bound was determined:

  • The Julia fixtures (test/fixtures/julia/data.json) contain 2003 test cases, yielding 4006 component assertions.
  • Measuring the single-precision ULP difference (via @stdlib/number/float32/base/ulp-difference) between the JavaScript implementation and the fixture values over the full fixture set gives a maximum of 1 ULP for both the real and imaginary components (376 of the 2003 cases differ by exactly 1 ULP; the remainder are exact). Hence, 1 is the minimum required ULP value, and the tests fail at 0.
  • The C implementation was measured independently by compiling src/main.c against its manifest dependency closure and running it over the same fixture inputs. It produces an identical error profile (maximum 1 ULP, the same 376 non-exact cases), which is expected given that the JavaScript and C implementations use the same algorithm (z / cabsf( z )). Accordingly, the same bound of 1 is used in test/test.native.js.
  • The package test suite was run twice at the final ULP value to confirm determinism; all 4018 assertions pass on both runs.

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, following the idiom established in previously merged conversions (e.g. #14080 for the double-precision csignum counterpart, #14327, and the atan2f conversion for the single-precision assertion variant). The ULP bound was measured empirically over the full fixture set rather than guessed, for both the JavaScript and C implementations.


@stdlib-js/reviewers


Generated by Claude Code

Replaces relative tolerance assertions with ULP difference assertions
using `@stdlib/number/float32/base/assert/is-almost-same-value`.

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 the Math Issue or pull request specific to math functionality. label Aug 17, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/csignumf $\\color{green}170/170$
$\\color{green}+100.00\\%$
$\\color{green}7/7$
$\\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 17, 2026
@kgryte
kgryte marked this pull request as ready for review August 17, 2026 22:24
@kgryte
kgryte requested a review from a team August 17, 2026 22:24
@kgryte
kgryte merged commit e463662 into develop Aug 17, 2026
50 checks passed
@kgryte
kgryte deleted the kgryte/ulp-csignumf branch August 17, 2026 22:25
@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. and removed Needs Review A pull request which needs code review. labels Aug 17, 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