Skip to content

test: migrate blas/base/dzasum to ULP-based assertions - #14893

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-dzasum
Sep 3, 2026
Merged

test: migrate blas/base/dzasum to ULP-based assertions#14893
kgryte merged 1 commit into
developfrom
kgryte/ulp-dzasum

Conversation

@kgryte

@kgryte kgryte commented Sep 2, 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 blas/base/dzasum from relative-tolerance assertions to ULP-difference assertions using @stdlib/assert/is-almost-same-value.
  • applies the migration to both test/test.dzasum.js and test/test.ndarray.js. The package has no test/test.native.js (no native implementation has landed yet), and test/test.js contains no tolerance-based assertions and is unchanged.
  • converts the shared private isApprox( t, actual, expected, rtol ) helper in each file to isApprox( t, actual, expected, ulp ), replacing the delta/tol computation with a single t.strictEqual( isAlmostSameValue( actual, expected, ulp ), true, 'returns expected value' ), mirroring the same-family conversion in blas/base/drotm (test: migrate blas/base/drotm to ULP-based assertions #14869).
  • introduces a per-test ULP constant, as in blas/base/drotm, and drops the now-unused abs and EPS requires.
  • preserves all existing test cases and every non-tolerance assertion (N <= 0, view offsets, offset support, arity, main export) exactly as-is.

ULP bounds

File Test ULP
test/test.dzasum.js computes the sum of absolute values 1
test/test.dzasum.js supports specifying a stride 1
test/test.dzasum.js supports specifying a negative stride 0
test/test.ndarray.js computes the sum of absolute values 1
test/test.ndarray.js supports specifying a stride 1
test/test.ndarray.js supports specifying a negative stride 0
test/test.ndarray.js supports specifying complex access patterns 0

Each value is the measured minimum. Starting from a loose bound and tightening, every assertion site was measured directly with @stdlib/number/float64/base/ulp-difference, and the result was confirmed by re-running the suite with the bounds tightened one step further:

  • The six sites carrying ULP = 1 have an exact measured ULP difference of 1 (e.g. dzasum( 4, x, 1 ) returns 1.5999999999999999 against an expected 1.6, and dzasum( 3, x, 1 ) returns 1.2999999999999998 against an expected 1.3). Lowering those blocks to ULP = 0 fails 3 assertions in test/test.dzasum.js and 3 assertions in test/test.ndarray.js, so 1 cannot be reduced.
  • The remaining sites are bit-for-bit exact and therefore use ULP = 0, which delegates to the SameValue algorithm. 0 is the tightest bound expressible.

Bounds this small are what one expects here: dzasum is a plain summation of abs( real ) and abs( imag ) over a short strided array, so the only error is the accumulated rounding of a handful of additions, and it never exceeds one ULP on these fixtures. The previous relative tolerance of 2.0 * EPS corresponds to roughly 2–4 ULP depending on where the expected value falls within its binade, so the new bounds are strictly tighter than the tolerances they replace.

The full package suite was run twice at the final bounds to confirm deterministic passing (26 assertions across the 3 test files, all passing on both runs, no FMA/architecture-dependent variation). Linting is clean: make eslint-tests TESTS_FILTER=".*/blas/base/dzasum/.*" reports no errors for either changed file. The only files changed are the two test files.

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 PR was authored by Claude Code: the assistant mechanically converted the tolerance-based assertions to isAlmostSameValue, agentically searched for the minimum ULP bound at every assertion site, verified minimality by re-running the suite one step tighter, confirmed determinism across repeated full runs, and ran the local lint and test suites before submitting.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01CfbAgTVeRuwnmFGvUZETog


Generated by Claude Code

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CfbAgTVeRuwnmFGvUZETog

---
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 BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Good First PR A pull request resolving a Good First Issue. labels Sep 2, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
blas/base/dzasum $\\color{green}226/226$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}226/226$
$\\color{green}+100.00\\%$

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

Copy link
Copy Markdown
Member

⚠️ Issue Reference Review

An automated check found potentially unrelated issue/PR references in this PR:

Reference Assessment Reasoning
#11352 suspicious Issue #11352 is an RFC explicitly scoped to migrating math/base/special packages from relative-tolerance testing to ULP-difference testing, but this PR modifies tests in blas/base/dzasum, a different package tree not covered by that RFC's stated scope.

Why this matters: GitHub automatically closes issues referenced with
closing keywords (Resolves, Closes, Fixes) when the PR is merged. Incorrect
references can accidentally close unrelated issues.

What to do:

  • If the reference is correct, no action needed. This check may produce
    false positives.
  • If the reference is incorrect, please update your PR description.

This assessment was generated by an AI model and is informational only.


Generated by Claude Code

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Sep 3, 2026
@kgryte
kgryte marked this pull request as ready for review September 3, 2026 03:15
@kgryte
kgryte requested a review from a team September 3, 2026 03:15
@kgryte
kgryte merged commit 68ac3f1 into develop Sep 3, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-dzasum branch September 3, 2026 03:16
@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 Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Good First PR A pull request resolving a Good First Issue. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants