Repository navigation
test: migrate blas/base/wasm/srotm to ULP-based assertions - #16060
Merged
Merged
Conversation
Replaces the computed relative tolerance assertions in the test files for `blas/base/wasm/srotm` with ULP-based assertions using `@stdlib/number/float32/base/assert/is-almost-same-value`. Each ULP bound was measured as the minimum integer number of ULPs which passes over the full set of test fixtures. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nmq7FgD5jskQ5tmDrLor8K
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
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/wasm/srotmfrom 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.main.js,test/test.ndarray.js,test/test.module.main.js, andtest/test.module.ndarray.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 floating-point numbers, the tests use the single-precision assertion utility (
isAlmostSameValuef), matching the convention already established by the sibling packagesblas/base/srotm(the non-WASM implementation of the same routine),blas/base/wasm/srot, andblas/base/wasm/drotm, 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
Float32Arrayagainst expectedFloat32Arrayvalues, inx/ypairs (actualX/actualYin the module test files). The measured minimum differs between the two members of a pair and between test cases, so each assertion carries its own bound rather than a single uniform value. The non-zero bounds are:xULPyULPtest/test.main.js10test/test.main.js01test/test.main.js12test/test.main.js10test/test.ndarray.js10test/test.ndarray.js01test/test.ndarray.js12test/test.ndarray.js10test/test.module.main.js10test/test.module.main.js01test/test.module.ndarray.js10test/test.module.ndarray.js01All remaining assertions (the stride, offset, negative stride, and complex access pattern test cases) are bit-exact against their expected values and so carry a bound of
0. In the module test files, the(sx=1, sy=1)case asserts twice (long and short datasets), and both assertion pairs require the same bounds. In total, 84 of the 100 call sites are exact (0), 14 require1, and 2 require2. This replaces the previous non-uniform relative tolerances of1.0,2.0,4.0,5.0, and10.0(i.e.,rtol * EPS * abs( expected )).The bounds were tightened empirically rather than guessed. The test helper was instrumented to report, for every call site, the smallest integer
ufor whichisAlmostSameValuef( actual[ i ], expected[ i ], u )holds for all elements, maximized over every invocation of that call site (several call sites are exercised repeatedly inside a loop overN). Each call site then received exactly that measured maximum, so2is the largest bound required anywhere in the package.Minimality was confirmed in both directions:
0failures;11,11,4, and4failing assertions intest/test.main.js,test/test.ndarray.js,test/test.module.main.js, andtest/test.module.ndarray.js, respectively — so none of the chosen bounds can be lowered.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.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
One: whether per-call-site bounds are preferred over a single uniform bound per test case. The issue asks for the minimum required ULP value, which is what is used here, and this matches
blas/base/wasm/srot. The siblingblas/base/srotminstead declares a singleULPvariable per test and uses it for both thexandyassertions. If reviewers prefer that shape, it is a small change and I am happy to make it.Other
Only the four test files containing tolerance-based assertions are modified; no source, documentation, benchmark, or fixture files are touched.
test/test.js,test/test.module.js, andtest/test.routine.jscontain no tolerance-based assertions and are 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/wasm/srotm/.*"—1129passing,0failing across all seven test files (416,440,128,104,27,8, and6). Run twice, with identical results.30failing assertions).etc/eslint/.eslintrc.tests.js—0errors. The four reportedmax-lenwarnings are pre-existing and present identically ondevelop..editorconfig, as theeditorconfig-checkerbinary could not be downloaded in the sandbox used to author this change.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 previously converted sibling packages in the same family (
blas/base/srotm,blas/base/wasm/srot,blas/base/wasm/drotm), applied the mechanical substitution to the four affected test files, and determined the ULP bounds by instrumenting the test helper to report the minimum passing ULP distance per call site, then confirming that lower bounds fail while the chosen bounds pass and re-running the suite to confirm the result is deterministic.@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01Nmq7FgD5jskQ5tmDrLor8K
Generated by Claude Code