Repository navigation
test: migrate blas/base/dznrm2 to ULP-based assertions - #16272
Merged
Merged
Conversation
Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PXiBYMSEGcZzLHx2zuU33q
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
4 of 7 tasks
kgryte
marked this pull request as ready for review
October 24, 2026 02:50
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:
migrates the tests for
blas/base/dznrm2from relative tolerance assertions to ULP-based assertions, following the same approach as the sibling migration forblas/base/scnrm2(test: migrateblas/base/scnrm2to ULP-based assertions #16261).removes the local
isApproxtest helper (along with the@stdlib/constants/float64/epsand@stdlib/math/base/special/absimports) and replaces each call site witht.strictEqual( isAlmostSameValue( actual, expected, <ulp> ), true, 'returns expected value' );, using@stdlib/assert/is-almost-same-value.tightens four truncated reference values so that the ULP comparison is meaningful. The removed helper iterated over
expected.length, but every call site passed a scalar return value, so the loop body never executed and the numeric results were effectively unasserted. As a result, several reference values had only been recorded to ~6 significant digits. The replacements are the correctly rounded double-precision values of the exact L2 norms and agree with the previously recorded digits:14.1→14.106735979665885(sqrt(199))2.82842e+150→2.82842712474619e+150(sqrt(8)*1e150)2.82843e-155→2.82842712474619e-155(sqrt(8)*1e-155)3.51283e-154→3.512833614050059e-154Each was computed independently at 80 decimal digits of precision and then correctly rounded to the nearest
float64, so the expectations remain independent references rather than a recording of implementation output.ULP bounds
Bounds were measured by instrumenting each assertion with
@stdlib/number/float64/base/ulp-differenceover every test case and then tightened to the minimum passing integer:test/test.dznrm2.js0test/test.ndarray.js0test/test.dznrm2.native.js1test/test.ndarray.native.js1The measured minimum for the JavaScript implementation is 0 ULP at every call site: against correctly rounded references,
dznrm2returns exactly the expected value. This is expected, since the scaled sum-of-squares accumulation only scales by powers of two (exact) before a correctly roundedsqrt.The native bounds could not be measured locally because the native add-on is not built in this environment (those tests skip), so they are set to a conservative
1, matching how the corresponding native test files were handled in #16261.The full package test suite was run twice at the final bounds to confirm determinism; both runs were green (
test.dznrm2.js: 9 passing,test.ndarray.js: 14 passing,test.js: 5 passing, native files skipped).make eslint-tests TESTS_FILTER=".*/blas/base/dznrm2/.*"is clean, and only test files are changed.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/scnrm2to ULP-based assertions #16261Questions
1e12, which would defeat the purpose of the migration. test: migrateblas/base/scnrm2to ULP-based assertions #16261 made the equivalent change for14.1→14.106736183166504, so this follows that precedent, but it is a larger set of values and worth a second look.0to match the JavaScript files instead of the conservative1? They were left at1since the bound could not be verified against a built add-on here.Other
Opened as a draft pending reviewer input on the two questions above.
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 scheduled task: it selected the package, studied the prior art in #11352 and #16261, applied the migration, measured the ULP bounds, and wrote this description.
@stdlib-js/reviewers
Generated by Claude Code