test: migrate math/base/special/binomcoeff to ULP-based testing #11720
Open
MANDEep22332 wants to merge 2 commits intostdlib-js:developfrom
Open
test: migrate math/base/special/binomcoeff to ULP-based testing #11720MANDEep22332 wants to merge 2 commits intostdlib-js:developfrom
math/base/special/binomcoeff to ULP-based testing #11720MANDEep22332 wants to merge 2 commits intostdlib-js:developfrom
Conversation
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
math/base/special/binomcoeff to ULP-based testing
kgryte
reviewed
Apr 23, 2026
| } | ||
| delta = absf( v - expected[ i ] ); | ||
|
|
||
| // NOTE: Exact comparison fails for large values due to single-precision floating-point rounding errors when intermediate results exceed the maximum safe integer for a 32-bit float. |
Member
There was a problem hiding this comment.
You need to preserve this comment.
kgryte
reviewed
Apr 23, 2026
| for ( i = 0; i < n.length; i++ ) { | ||
| v = binomcoeff( n[ i ], k[ i ] ); | ||
| expected[ i ] = float64ToFloat32( expected[ i ] ); | ||
| if ( expected[ i ] === v ) { |
Member
There was a problem hiding this comment.
This branch is no longer necessary.
kgryte
reviewed
Apr 23, 2026
| // NOTE: Exact comparison fails for large values due to single-precision floating-point rounding errors when intermediate results exceed the maximum safe integer for a 32-bit float. | ||
| tol = 1.25 * EPS * absf( expected[ i ] ); | ||
| t.ok( delta <= tol, 'within tolerance. n: ' + n[ i ] + '. k: ' + k[ i ] + '. actual: ' + v + '. expected: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ); | ||
| t.strictEqual(isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value'); |
Member
There was a problem hiding this comment.
Suggested change
| t.strictEqual(isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value'); | |
| t.strictEqual( isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' ); |
Spacing.
kgryte
reviewed
Apr 23, 2026
| for ( i = 0; i < n.length; i++ ) { | ||
| v = binomcoeff( n[ i ], k[ i ] ); | ||
| expected[ i ] = float64ToFloat32( expected[ i ] ); | ||
| t.strictEqual( v, expected[ i ], 'returns expected value. actual: '+v+'. expected: '+expected[i]+'. n: '+n[i]+'. k: '+k[i]+'.' ); |
Member
There was a problem hiding this comment.
Why did you replace a strictEqual check? If the results are exactly equal already, we don't need to migrate to isAlmostSameValue.
Contributor
Author
|
@kgryte , pls review the changes in the code |
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.
Progresses #11352
Description
This pull request:
Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
{{TODO: add disclosure if applicable}}
@stdlib-js/reviewers