Skip to content

test: migrate blas/base/cscal to ULP-based assertions - #16288

Merged
kgryte merged 1 commit into
developfrom
claude/great-brahmagupta-koipn1
Oct 23, 2026
Merged

kgryte merged 1 commit into
developfrom
claude/great-brahmagupta-koipn1

Conversation

@kgryte

@kgryte kgryte commented Oct 21, 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/cscal from relative tolerance testing (delta <= rtol * EPS * abs( expected )) to ULP difference testing using @stdlib/number/float32/base/assert/is-almost-same-value.
  • replaces the EPS/abs imports with isAlmostSameValuef and introduces the private isApprox test helper which accepts a maximum allowed ULP difference, matching the idiom used in already migrated sibling packages (e.g., blas/base/wasm/cscal, blas/base/csrot, and blas/base/caxpy).
  • tightens each assertion to the minimum ULP value which still passes over the full set of test cases.

Files changed (test files only):

  • test/test.cscal.js
  • test/test.cscal.native.js
  • test/test.ndarray.js
  • test/test.ndarray.native.js

test/test.js contains no tolerance-based comparisons and is left unchanged.

Measured minimum ULP bounds (per test case, in file order):

File ULP values
test/test.cscal.js 1, 1, 1, 2
test/test.cscal.native.js 1, 1, 1, 2
test/test.ndarray.js 1, 1, 1, 5, 5
test/test.ndarray.native.js 1, 1, 1, 5, 5

These values coincide exactly with those used in the already migrated blas/base/wasm/cscal, which exercises the same inputs and expected values.

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 suites could not be executed locally, as the native add-on was not built in the development environment (the suites were skipped via tryRequire; building requires gfortran, which was unavailable). Following the convention in previously migrated packages, the native test files use the same per-test-case ULP values as their JavaScript counterparts. Please flag if the C implementation is expected to diverge for any of these cases.

Other

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

How the bounds were determined:

  • The maximum observed ULP difference was measured for every test case over the full set of expected values using @stdlib/number/float32/base/ulp-difference.
  • Each bound was then confirmed to be minimal: at N, the suite passes; at N-1, the corresponding test case fails.
  • The suites were run twice at the final values, with identical results, to confirm determinism (test/test.js: 5 passing, test/test.cscal.js: 52 passing, test/test.ndarray.js: 73 passing, 0 failing; native suites skipped).
  • make lint-javascript-tests TESTS_FILTER=".*/blas/base/cscal/.*" is clean.

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 authored by Claude Code, running as an unattended automated task. The test migration, the ULP measurements, and the minimality verification were performed by Claude Code; the approach mirrors the idiom established in previously merged migrations for this package family.


@stdlib-js/reviewers


Generated by Claude Code

Replaces relative tolerance comparisons in the `blas/base/cscal` test
suites with ULP difference assertions based on
`@stdlib/number/float32/base/assert/is-almost-same-value`, mirroring the
idiom used in already migrated sibling packages. Each assertion uses the
minimum ULP value which still passes over the full set of test cases.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NZTNUssj4xAturDdYEaq9q

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
blas/base/cscal $\\color{green}379/379$
$\\color{green}+100.00\\%$
$\\color{green}17/17$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}379/379$
$\\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 23, 2026
@kgryte
kgryte marked this pull request as ready for review October 23, 2026 18:34
@kgryte
kgryte requested a review from a team October 23, 2026 18:34
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Oct 23, 2026
@kgryte
kgryte merged commit eeebc88 into develop Oct 23, 2026
82 checks passed
@kgryte
kgryte deleted the claude/great-brahmagupta-koipn1 branch October 23, 2026 18:37
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Oct 23, 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.

3 participants