feat: add stats/incr/nanmrss#6197
Conversation
|
Hello! 👋 We've noticed that you've been opening a number of PRs addressing good first issues. Thank you for your interest and enthusiasm! Now that you've made a few contributions, we suggest no longer working on good first issues. Instead, we encourage you to prioritize cleaning up any PRs which have yet to be merged and then proceed to work on more involved tasks. Not only does this ensure that other new contributors can work on things and get ramped up on all things stdlib, it also ensures that you can spend your time on more challenging problems. 🚀 For ideas for future PRs, feel free to search the codebase for TODOs and FIXMEs and be sure to check out other open issues on the issue tracker. Cheers! |
Coverage Report
The above coverage report was generated for the changes in this PR. |
stats/incr/nanmrssstats/incr/nanmrss
hrshya
left a comment
There was a problem hiding this comment.
The img directory is also missing in docs.
|
|
||
| #### incrnanmrss( window ) | ||
|
|
||
| Returns an accumulator `function` which incrementally computes a moving [residual sum of squares][residual-sum-of-squares]. The `window` parameter defines the number of values over which to compute the moving [residual sum of squares][residual-sum-of-squares]. |
There was a problem hiding this comment.
Needs to add , ignoring NaN values. at the end.
| /** | ||
| * If provided arguments, returns an updated residual sum of squares; otherwise, returns the current residual sum of squares, ignoring `NaN` values. | ||
| * | ||
| * ## Notes |
| * @returns {(number|null)} residual sum of squares or null | ||
| */ | ||
| function accumulator( x, y ) { | ||
| if ( arguments.length === 0 ) { |
There was a problem hiding this comment.
Instead of using two if statements. This can be done in a single if statement. (L79-84)
|
@hrshya you can review this PR again, i have resolved the errors |
On it! |
There was a problem hiding this comment.
@jalajk3004 Can you also change the description to:
adds stats/incr/nanmrss .
|
|
||
| # incrnanmrss | ||
|
|
||
| > Compute a moving [residual sum of squares][residual-sum-of-squares] (RSS) incrementally, ignoring `NaN` calues. |
There was a problem hiding this comment.
Typo.
| > Compute a moving [residual sum of squares][residual-sum-of-squares] (RSS) incrementally, ignoring `NaN` calues. | |
| > Compute a moving [residual sum of squares][residual-sum-of-squares] (RSS) incrementally, ignoring `NaN` values. |
| if ( arguments.length === 0 || isnan( x ) || isnan( y ) ) { | ||
| return mrss(); | ||
| } | ||
| return mrss( ( ( isnan( x ) ) ? 0 : x), ( ( isnan( y ) ) ? 0 : y ) ); |
There was a problem hiding this comment.
Dead code. Line 79 already returns early when either x or y is NaN, so the isnan ternaries are unreachable.
| return mrss( ( ( isnan( x ) ) ? 0 : x), ( ( isnan( y ) ) ? 0 : y ) ); | |
| return mrss( x, y ); |
| * @returns accumulator function | ||
| * | ||
| * @example | ||
| * var accumulator = incrmrss( 3 ); |
There was a problem hiding this comment.
Wrong function name.
| * var accumulator = incrmrss( 3 ); | |
| * var accumulator = incrnanmrss( 3 ); |
| v1 = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( 0.0, 100.0 ); | ||
| v2 = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( 0.0, 100.0 ); | ||
| rss = accumulator( v1, v2 ); | ||
| console.log( '%s\t%s\t%s', ((Number.isNaN(v1)) ? 'NaN' : v1.toFixed(3)), ((Number.isNaN(v2)) ? 'NaN' : v2.toFixed(3)), (((rss !== null) && (!Number.isNaN(rss))) ? rss.toFixed(3) : 'null')); |
There was a problem hiding this comment.
Number.isNaN is ES6. Examples must be ES5. Also missing spaces inside parentheses. See mrss/examples/index.js.
Requested changes applied in the maintainer cleanup commit: removed the dead-code NaN ternaries, fixed the incrmrss -> incrnanmrss example, replaced ES6 Number.isNaN in the example, and fixed the README typo/annotations. Dismissing the stale review.
3880010 to
1fef29f
Compare
- Remove unreachable NaN-guard ternaries in the accumulator return (the early guard already returns on NaN); forward x and y directly - Fix incrmrss -> incrnanmrss in the index.d.ts example - Use @stdlib/math/base/assert/is-nan instead of ES6 Number.isNaN in the example and add conventional spacing - Fix the README 'calues' typo and correct misleading window annotations for ignored NaN pairs - Drop backticks from package.json description; bump copyright year to 2026
PR Commit MessagePlease review the above commit message and make any necessary adjustments. |
|
@Planeshifter Not sure why, but all the linting in this PR was a no-op in CI: https://github.com/stdlib-js/stdlib/actions/runs/28843282273/job/85541581494?pr=6197 Worthwhile to always merge in the latest |
|
I noticed this, as CI failed after merging to |
Resolves #5607
Description
This pull request:
Related Issues
This pull request:
stats/incr/nanmrss#5607Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers