feat: add stats/strided/nancumax#11307
feat: add stats/strided/nancumax#11307parthodas23 wants to merge 2 commits intostdlib-js:developfrom
stats/strided/nancumax#11307Conversation
b26bdd4 to
b303abc
Compare
Coverage Report
The above coverage report was generated for the changes in this PR. |
| for ( i = min; i <= max; i++ ) { | ||
| len = pow( 10, i ); | ||
| f = createBenchmark( len ); | ||
| bench( pkg+':len='+len, f ); |
There was a problem hiding this comment.
@parthodas23 Mind updating this to use string interpolation instead of concatenation? Cheers!
| for ( i = min; i <= max; i++ ) { | ||
| len = pow( 10, i ); | ||
| f = createBenchmark( len ); | ||
| bench( pkg+':ndarray:len='+len, f ); |
| * var y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); | ||
| * | ||
| * var v = nancumax( 6, arraylike2object( x ), 1, 0, arraylike2object( y ), 1, 0 ); | ||
| * // returns <Object> |
There was a problem hiding this comment.
This isn't a good use of doctesting, as it doesn't actually validate the implementation.
| * var x = toAccessorArray( [ 2.0, 1.0, 2.0, -2.0, NaN, 4.0 ] ); | ||
| * var y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); | ||
| * | ||
| * var v = nancumax( 6, arraylike2object( x ), 1, 0, arraylike2object( y ), 1, 0 ); | ||
| * // returns <Object> |
There was a problem hiding this comment.
| * var x = toAccessorArray( [ 2.0, 1.0, 2.0, -2.0, NaN, 4.0 ] ); | |
| * var y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); | |
| * | |
| * var v = nancumax( 6, arraylike2object( x ), 1, 0, arraylike2object( y ), 1, 0 ); | |
| * // returns <Object> | |
| * var x = [ 2.0, 1.0, 2.0, -2.0, NaN, 4.0 ]; | |
| * var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; | |
| * | |
| * nancumax( 6, arraylike2object( toAccessorArray( x ) ), 1, 0, arraylike2object( toAccessorArray( y ) ), 1, 0 ); | |
| * // x => [ 2.0, 2.0, 2.0, 2.0, 2.0, 4.0 ] |
| if ( N <= 0 ) { | ||
| return y; | ||
| } |
There was a problem hiding this comment.
This check shouldn't be here, as it is unreachable via the main export.
| } | ||
| ix = offsetX; | ||
| iy = offsetY; | ||
| max = -Infinity; |
There was a problem hiding this comment.
Why are you using -Infinity? I thought we discussed this elsewhere. Namely, have a loop which searches for the first non-NaN value. Until that time, fill the output array with NaNs. Once you find the first non-NaN, set max equal to that value and then proceed as you have done below.
| } | ||
| ix = offsetX; | ||
| iy = offsetY; | ||
| max = -Infinity; |
There was a problem hiding this comment.
If you start with -Infinity, how is a user supposed to distinguish between when x contains -Infinities and when it contains NaNs? The answer is they can't. That is why you need to fill with NaNs until the first non-NaN value.
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the function computes the cumulative maximum of a strided array', function test( t ) { |
There was a problem hiding this comment.
You need to add test examples for when the input array starts with NaN values to demonstrate expected behavior.
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the function computes the cumulative maximum of a strided array', function test( t ) { |
Co-authored-by: Athan <kgryte@gmail.com> Signed-off-by: Athan <kgryte@gmail.com>
Resolves #305 .
Description
This pull request:
stats/strided/nancumaxRelated Issues
This pull request has the following related issues:
stats/strided/nancumax#305Questions
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