feat: add stats/incr/nanrss#10082
Conversation
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: passed
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: passed
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
|
@nakul-krishnakumar @kgryte @Planeshifter Kindly review my PR. |
|
|
||
| ## Notes | ||
|
|
||
| - Input values are **not** type checked. If provided `NaN` or a value which, when used in computations, results in `NaN`, the accumulated value is `NaN` for **all** future invocations. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function. |
There was a problem hiding this comment.
This note was copied from incr/rss and directly contradicts the purpose of this package. The whole point of nanrss is to ignore NaN values. Should be:
| - Input values are **not** type checked. If provided `NaN` or a value which, when used in computations, results in `NaN`, the accumulated value is `NaN` for **all** future invocations. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function. | |
| - Input values are **not** type checked. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function. |
| if ( arguments.length === 0 ) { | ||
| return nansum(); | ||
| } | ||
| if ( x !== x || y !== y ) { |
There was a problem hiding this comment.
Use isnan from @stdlib/math/base/assert/is-nan. All other nan-wrapper packages do. Also, the standard pattern is to wrap the non-nan base accumulator directly (i.e., wrap incrrss, not incrnansum) — see nanmstdev which wraps incrmstdev.
| * r = accumulator( NaN, 3.0 ); | ||
| * // 50.0 | ||
| * r = accumulator( 5.0, NaN ); | ||
| * // 50.0 |
There was a problem hiding this comment.
Missing returns:
| * r = accumulator( NaN, 3.0 ); | |
| * // 50.0 | |
| * r = accumulator( 5.0, NaN ); | |
| * // 50.0 | |
| * r = accumulator( NaN, 3.0 ); | |
| * // returns 50.0 | |
| * r = accumulator( 5.0, NaN ); | |
| * // returns 50.0 |
|
|
||
| #### accumulator( \[x, y] ) | ||
|
|
||
| If provided input values x and y, the accumulator function updates the RSS. If NaN is provided, it is ignored, and the previous RSS is returned. If no arguments are provided, the accumulator function returns the current RSS. |
There was a problem hiding this comment.
Doesn't match the style in incr/rss. Parameters should be in backticks, use the full term with link references, and follow the standard phrasing. Compare with incr/rss README.
| @@ -0,0 +1,31 @@ | |||
| {{alias}}() | |||
There was a problem hiding this comment.
Missing leading blank line. All repl.txt files start with an empty line before {{alias}}.
Resolves #5622
Description
This pull request:-
Adds an incremental residual sum of squares (RSS) accumulator.
Ignores
NaNinput values during accumulation.Returns the previously accumulated RSS when inputs contain
NaNPasses all existing test cases and maintains backward compatibility.
Other
Result for benchmark:-
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
@stdlib-js/reviewers