Skip to content

test: migrate blas/base/drot to ULP-based assertions - #15025

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-drot
Sep 6, 2026
Merged

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

Conversation

@kgryte

@kgryte kgryte commented Sep 6, 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/drot from relative tolerance testing to ULP difference testing, replacing the rtol * EPS * abs( expected ) comparisons in the isApprox helper with @stdlib/assert/is-almost-same-value. The idiom mirrors the already-migrated sibling package blas/base/drotm.

Files changed: test/test.drot.js, test/test.drot.native.js, test/test.ndarray.js, and test/test.ndarray.native.js. No non-test files are modified, and no test fixtures, expected values, or test cases were added, removed, or altered.

Each ULP constant is the measured minimum for its fixture set. Bounds were determined by computing, for every compared element, the smallest n for which isAlmostSameValue( actual, expected, n ) returns true, and taking the per-test maximum. Each bound was then verified to be minimal by confirming that the test fails at ULP - 1.

test/test.drot.js and test/test.drot.native.js:

Test ULP Previous rtol
applies a plane rotation (sx=1, sy=1) 5 6.0
applies a plane rotation (sx=2, sy=-2) 21 20.0
applies a plane rotation (sx=-2, sy=1) 21 20.0
applies a plane rotation (sx=-1, sy=-2) 5 4.0
supports an x stride 2 2.0
supports negative strides 21 20.0
supports complex access patterns 5 5.0

test/test.ndarray.js and test/test.ndarray.native.js:

Test ULP Previous rtol
applies a plane rotation (sx=1, sy=1) 5 6.0
applies a plane rotation (sx=2, sy=-2) 21 20.0
applies a plane rotation (sx=-2, sy=1) 21 20.0
applies a plane rotation (sx=-1, sy=-2) 5 4.0
supports an x stride 2 2.0
supports an x offset 2 2.0
supports a y stride 0 1.0
supports a y offset 1 1.0
supports negative strides 21 20.0
supports complex access patterns 5 5.0

Tests using exact assertions (t.deepEqual) were left unchanged.

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 21 ULP bounds are driven by a single element in each of those fixture sets. For the (sx=2, sy=-2) case, the last rotated x element is 0.8*(-0.4) + 0.6*0.5, which is subject to catastrophic cancellation: the computed value is -0.020000000000000073 against an expected literal of -0.02. The previous relative tolerance (20 * EPS * abs( expected )) permitted roughly 25 ULP at that magnitude, so 21 is a tightening rather than a relaxation, but reviewers may prefer a different treatment of that fixture.

Other

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

The bounds above were measured against the JavaScript implementations. The native test files use the same bounds, matching the convention in the already-migrated blas/base/drotm and blas/base/srotm. The native add-on could not be built locally (gfortran is unavailable in the environment used to author this change), so the native bounds are unverified locally and rely on CI. Marked as a draft for that reason.

The JavaScript test suite was run twice at the final bounds with identical results (326 assertions in test.drot.js, 360 in test.ndarray.js, all passing), confirming determinism.

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. The migration follows the idiom established in the already-migrated blas/base/drotm, and the ULP bounds were measured empirically rather than guessed.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01JXfLRBopGnbspYy9pzBY29


Generated by Claude Code

Replaces the relative tolerance assertions in the `blas/base/drot` tests
with ULP-based assertions using `@stdlib/assert/is-almost-same-value`,
mirroring the conventions established in `blas/base/drotm`.

Each ULP bound is the measured minimum required by the corresponding
fixture set.

Ref: #11352

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

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

Copy link
Copy Markdown
Contributor

Hello! 👋

We've noticed that you've been opening a number of PRs addressing good first issues. Thank you for your interest and enthusiasm!

Now that you've made a few contributions, we suggest no longer working on good first issues. Instead, we encourage you to prioritize cleaning up any PRs which have yet to be merged and then proceed to work on more involved tasks.

Not only does this ensure that other new contributors can work on things and get ramped up on all things stdlib, it also ensures that you can spend your time on more challenging problems. 🚀

For ideas for future PRs, feel free to search the codebase for TODOs and FIXMEs and be sure to check out other open issues on the issue tracker. Cheers!

@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
blas/base/drot $\\color{green}398/398$
$\\color{green}+100.00\\%$
$\\color{green}19/19$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}398/398$
$\\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 Sep 6, 2026
@kgryte
kgryte marked this pull request as ready for review September 6, 2026 06:29
@kgryte
kgryte requested a review from a team September 6, 2026 06:29
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 6, 2026
@kgryte
kgryte merged commit 497e0b1 into develop Sep 6, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-drot branch September 6, 2026 06:32
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 6, 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