Skip to content

test: migrate blas/base/zaxpy to ULP-based assertions - #16094

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-blas-base-zaxpy
Oct 13, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-blas-base-zaxpy

Conversation

@kgryte

@kgryte kgryte commented Oct 12, 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/zaxpy from relative tolerance testing to ULP difference testing.
  • replaces the isApprox test helper's delta/tol computation (rtol * EPS * abs( expected[ i ] )) with isAlmostSameValue( actual[ i ], expected[ i ], ulp ) from @stdlib/assert/is-almost-same-value, dropping the now unused @stdlib/constants/float64/eps and @stdlib/math/base/special/abs imports and normalizing all assertion messages to 'returns expected value'.
  • replaces the previous blanket rtol of 14.0 at every call site with the minimum required ULP bound for that call site.

The migration mirrors the idiom already used by the single-precision sibling package blas/base/caxpy, which passes a per-call-site integer ULP bound to the same isApprox helper shape.

Files changed (test files only):

  • test/test.zaxpy.js
  • test/test.zaxpy.native.js
  • test/test.ndarray.js
  • test/test.ndarray.native.js

Measured ULP bounds

Each bound below is the measured minimum: the suite passes at the stated value and fails at the value minus one. Bounds were determined by instrumenting isApprox with @stdlib/number/float64/base/ulp-difference to record the maximum observed ULP difference per call site, and then independently confirmed by re-running each call site at N-1.

test/test.zaxpy.js and test/test.zaxpy.native.js (identical bounds):

Test case ULP
scales elements from x by alpha and adds the result to y 24
supports an x stride 8
supports a y stride 6
supports negative x strides 24
supports negative y strides 8
supports complex access patterns 6
supports view offsets 24

test/test.ndarray.js and test/test.ndarray.native.js (identical bounds; the native file additionally covers dcabs1( alpha ) === 0.0):

Test case ULP
scales elements from x by alpha and adds the result to y 24
dcabs1( alpha ) === 0.0 returns the second input array unchanged (native only) 0
supports an x stride 8
supports an x offset 11
supports a y stride 6
supports a y offset 1
supports a negative x stride 24
supports a negative y stride 8
supports complex access patterns 6

The maximum bound (24 ULP) is driven by the hand-written decimal expected fixtures rather than by the implementation; the same effect is visible in blas/base/caxpy, whose corresponding cases converted to 15 ULP.

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?

The native test files were exercised against a locally built addon, and their measured bounds came out identical to the JavaScript ones, so the JS and native files carry the same values. Happy to adjust if a different convention is preferred for the 0 ULP case in test/test.ndarray.native.js, where isAlmostSameValue falls back to exact SameValue comparison.

Other

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

Verification performed:

  • make test TESTS_FILTER=".*/blas/base/zaxpy/.*" — 496 assertions passing across all five test files (test.js, test.zaxpy.js, test.zaxpy.native.js, test.ndarray.js, test.ndarray.native.js), run three times with identical results to rule out arch/FMA nondeterminism.
  • make lint-javascript-tests TESTS_FILTER=".*/blas/base/zaxpy/.*" — clean.
  • The native tests were run against an addon built locally (node-gyp rebuild), so the native bounds are measured rather than inferred.
  • Only the four test files listed above are modified; no source, documentation, or benchmark files are touched.

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

This PR was written primarily by Claude Code, running as an unattended task: it selected the package, studied the already-converted sibling packages (blas/base/caxpy, blas/base/zdrot) to match the established idiom, performed the migration, and measured and minimized each ULP bound.


@stdlib-js/reviewers


Generated by Claude Code

Replace the relative-tolerance `isApprox` helper with ULP difference
testing via `@stdlib/assert/is-almost-same-value`, tightening each
assertion to the minimum required ULP bound.

Ref: #11352

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

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
blas/base/zaxpy $\\color{green}417/417$
$\\color{green}+100.00\\%$
$\\color{green}18/18$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}417/417$
$\\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 Oct 13, 2026
@kgryte
kgryte marked this pull request as ready for review October 13, 2026 10:35
@kgryte
kgryte requested a review from a team October 13, 2026 10:35
@kgryte
kgryte merged commit f14d9dd into develop Oct 13, 2026
66 checks passed
@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 Oct 13, 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.

2 participants