Conversation
Migrates the tests for `blas/base/csrot` from relative tolerance testing to ULP difference testing by replacing the computed `delta`/`tol` comparisons in the `isApprox` test helper with `@stdlib/number/float32/base/assert/is-almost-same-value`. The ULP bounds were tightened empirically to their measured minima: `0` for the `viewX` assertions (bit-exact) and `1` for the `viewY` assertions. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GM1tQCdB4tfVPW72Q5eaAo
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves a part of #11352.
Description
This pull request:
blas/base/csrotfrom relative tolerance testing to ULP difference testing, replacing the computeddelta/tolcomparisons with@stdlib/number/float32/base/assert/is-almost-same-value.Concretely, in each of
test/test.csrot.js,test/test.csrot.native.js,test/test.ndarray.js, andtest/test.ndarray.native.js, the following helperis replaced by
along with adding the
@stdlib/number/float32/base/assert/is-almost-same-valuerequire and dropping the now-unused@stdlib/math/base/special/absand@stdlib/constants/float32/epsrequires.As this package operates on single-precision complex floating-point numbers, the tests use the single-precision assertion utility (
isAlmostSameValuef), matching the convention already established by the sibling packageblas/base/wasm/csrot(#15871), whose converted test files use the sameisApprox( t, actual, expected, ulp )helper shape with a per-call-site integer ULP bound.ULP bounds
Every tolerance-based assertion in this package compares a
Float32Arrayview against expectedFloat32Arrayvalues, inviewX/viewYpairs. The measured minimum differs between the two members of each pair, so each assertion carries its own bound rather than a single uniform value:isApprox( t, viewX, xe, ... )00isApprox( t, viewY, ye, ... )11The bounds are identical across all four files and across all test cases (plane rotation,
xstride,xoffset,ystride,yoffset, negative strides, complex access patterns, and view offsets), replacing the previous uniform2.0relative tolerance (i.e.,2.0 * EPS * abs( expected )) at every call site.The bounds were tightened empirically rather than guessed. Starting from a high value and lowering it, the
viewXresults are bit-exact against the expected values and so pass at0, while theviewYresults differ by exactly one ULP and so fail at0and pass at1:So
1is the tightest possible non-exact bound for theviewYassertions, and theviewXassertions require no tolerance at all. Minimality was confirmed in both directions: lowering theviewYbound to0makestest/test.csrot.jsfail (113 passing, 9 failing) andtest/test.ndarray.native.jsfail (129 passing, 12 failing), while the chosen bounds pass everywhere.Notably, the JavaScript and native implementations agree bit-for-bit on these fixtures, so the same bounds apply to both; no JS-vs-C divergence had to be accommodated. To establish this rather than assume it, the native add-on was compiled locally (
make install-node-addons NODE_ADDONS_PATTERN="blas/base/csrot") so thattest/test.csrot.native.jsandtest/test.ndarray.native.jsactually executed rather than being skipped viatryRequire.The full test suite was run twice at the final values to confirm the result is stable (no FMA/arch-dependent variation); both runs report identical passing counts and
0failures.Note that the prior state of this package applied a uniform
2.0 * EPSrelative tolerance to both members of each pair, which is why theviewXcases were not previously distinguishable as exact. If reviewers would prefer a uniform1in both positions — trading the tighter bound for robustness against a future bit-level change in the implementation — that is a one-character change per call site and I am happy to make it.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352blas/base/wasm/csrotto ULP-based assertions #15871 (sibling migration forblas/base/wasm/csrot, whose idiom this PR mirrors)Questions
Only the one noted above: whether the exact (
0ULP) bound on theviewXassertions is preferred over a uniform1, given that the issue asks for the minimum required ULP value.Other
Only the four test files containing tolerance-based assertions are modified; no source, documentation, benchmark, or fixture files are touched.
test/test.jscontains no tolerance-based assertions and is left unchanged. The assertion count is unchanged by this migration, as the removed exact/approximate branch emitted exactly one assertion per element either way.Verification performed:
make test TESTS_FILTER=".*/blas/base/csrot/.*"—531passing,0failing across all five test files (122+122+141+141+5), with the native tests executing rather than skipping. Run twice, with identical results.viewYbound lowered to0, which fails as expected.make lint-javascript-tests TESTS_FILTER=".*/blas/base/csrot/.*"— clean,0problems across all files..editorconfig, as theeditorconfig-checkerbinary could not be downloaded in the sandbox used to author this change. The four pre-existing trailing-whitespace lines in these files are untouched by this diff (git diff --checkis clean).Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code running as an unattended task. It studied the migration idiom from the previously converted sibling packages in the same family (
blas/base/wasm/csrot,blas/base/zdrot), applied the mechanical substitution to the four affected test files, and determined the ULP bounds by instrumenting the test helper to report the maximum observed ULP distance per call site, then confirming that a lower bound fails while the chosen bound passes and re-running the suite to confirm the result is deterministic.@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01GM1tQCdB4tfVPW72Q5eaAo
Generated by Claude Code