Repository navigation
test: migrate blas/base/wasm/drot to ULP-based assertions - #16068
Merged
Merged
Conversation
Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U13odwDmveF3gMu47iWxXA
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/drotfrom relative tolerance testing to ULP difference testing, replacing the computeddelta/tolcomparisons with@stdlib/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/assert/is-almost-same-valuerequire and dropping the now-unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires.As this package operates on double-precision floating-point numbers, the tests use the double-precision assertion utility (
isAlmostSameValue), matching the convention already established by the sibling packagesblas/base/drot(the non-WASM implementation of the same routine),blas/base/wasm/drotm, andblas/base/wasm/srot, 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
Float64Arrayagainst expectedFloat64Arrayvalues, 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.rtolxULPyULPtest/test.main.js6.015test/test.main.js20.0215test/test.main.js20.0215test/test.main.js4.005test/test.main.jsxstride2.012test/test.main.js20.0212test/test.main.js5.005test/test.ndarray.js6.015test/test.ndarray.js20.0215test/test.ndarray.js20.0215test/test.ndarray.js4.005test/test.ndarray.jsxstride2.012test/test.ndarray.jsxoffset2.012test/test.ndarray.jsystride1.000test/test.ndarray.jsyoffset1.001test/test.ndarray.js20.0212test/test.ndarray.js5.005test/test.module.main.js6.015test/test.module.main.js20.0212test/test.module.main.js20.0212test/test.module.main.js4.005test/test.module.main.jsxstride6.012test/test.module.main.jsystride6.000test/test.module.main.js20.0212test/test.module.main.js6.005test/test.module.ndarray.js6.015test/test.module.ndarray.js20.0212test/test.module.ndarray.js20.0212test/test.module.ndarray.js4.005test/test.module.ndarray.jsxstride6.012test/test.module.ndarray.jsxoffset6.012test/test.module.ndarray.jsystride6.000test/test.module.ndarray.jsyoffset6.001test/test.module.ndarray.js20.0212test/test.module.ndarray.js6.005Across the 70 call sites, 16 are bit-exact (
0), 12 require1, 14 require2, 16 require5, and 12 require21. This replaces the previous non-uniform relative tolerances of1.0,2.0,4.0,5.0,6.0, and20.0(i.e.,rtol * EPS * abs( expected )). Note that a relative tolerance ofrtol * EPSadmits betweenrtoland2*rtolULPs depending on where the expected value falls within its binade, which is why the stridedxcases measure21against a previousrtolof20.0.The bounds were tightened empirically rather than guessed. The test helper was instrumented to report, for every call site, the maximum ULP distance between actual and expected over all elements and over every invocation of that call site (several call sites are exercised repeatedly inside a loop over
N). Each call site then received exactly that measured maximum.Minimality was confirmed in both directions:
0failures;The full suite was run twice at the final values to confirm the result is stable (no FMA/arch-dependent variation); both runs report
1007passing assertions and0failures.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/srotandblas/base/wasm/drotm. If reviewers prefer a singleULPvariable declared per test, asblas/base/srotmdoes, that 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; this was verified by running the pre-migration and post-migration files side by side (326,360,128, and152assertions in each case).Verification performed:
make test TESTS_FILTER=".*/blas/base/wasm/drot/.*"—1007passing,0failing across all seven test files (326,360,128,152,27,8, and6). Run twice, with identical results.make lint-javascript-tests TESTS_FILTER=".*/blas/base/wasm/drot/.*"— clean. ESLint usingetc/eslint/.eslintrc.tests.jsdirectly also reports0errors and0warnings..editorconfig, andgit diff --checkis clean. Theeditorconfig-checkerbinary could not be downloaded in the sandbox used to author this change, so thelint-editorconfig-filestarget itself could not run.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/drot,blas/base/wasm/drotm,blas/base/wasm/srot), applied the mechanical substitution to the four affected test files, and determined the ULP bounds by instrumenting the test helper to report the maximum 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_01U13odwDmveF3gMu47iWxXA
Generated by Claude Code