Skip to content

feat: add stats/incr/nanwmean - #5632

Closed
pranav-1720 wants to merge 5 commits into
stdlib-js:developfrom
pranav-1720:nanwmean
Closed

pranav-1720 wants to merge 5 commits into
stdlib-js:developfrom
pranav-1720:nanwmean

Conversation

@pranav-1720

@pranav-1720 pranav-1720 commented Mar 1, 2025 •

Copy link
Copy Markdown
Contributor

Resolves #5628.

Description

What is the purpose of this pull request?

This pull request:

  • This Pull request adds the package stats/incr/nanwmean which is a wrapper around stats/incr/wmean to handle NaN values

Related Issues

Does this pull request have any related issues?

No.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

---
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: 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: 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: 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. labels Mar 1, 2025
@stdlib-bot

stdlib-bot commented Mar 1, 2025 •

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/incr/nanwmean $\color{green}141/141$
$\color{green}+100.00\%$
$\color{green}8/8$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}141/141$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this PR.

@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Mar 1, 2025
Signed-off-by: pranav-1720 <123018993+pranav-1720@users.noreply.github.com>
Signed-off-by: pranav-1720 <123018993+pranav-1720@users.noreply.github.com>
@pranav-1720

Copy link
Copy Markdown
Contributor Author

Hi, almost all the required files have been added to close the issues. I am just unsure what is needed for the repl.txt and image files like which are added in the nansum package. When adding repl.txt, i get module not found errors while commiting. Are these files supposed to be system generated?

---
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: na
  - 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: passed
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added the Potential Duplicate There might be another pull request resolving the same issue. label Apr 19, 2025

@Planeshifter Planeshifter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case there is still interest in moving this PR forward, I left some feedback. Sorry it took so long!

// MAIN //

/**
* Returns an accumulator function which incrementally computes a sum, ignoring `NaN` values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Says "computes a sum" — should be "weighted arithmetic mean".

Suggested change
* Returns an accumulator function which incrementally computes a sum, ignoring `NaN` values.
* Returns an accumulator function which incrementally computes a weighted arithmetic mean, ignoring `NaN` values.

* mu = accumulator( 3.0, 1.5 );
* // returns 2.5
*
* mu = accumulator (2.0, NaN );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before ( — should be accumulator( 2.0, NaN ). Same on line 46 in docs/types/index.d.ts.

Suggested change
* mu = accumulator (2.0, NaN );
* mu = accumulator( 2.0, NaN );

type accumulator = ( x?: number, w?: number ) => number | null;

/**
* Returns an accumulator function which incrementally computes a weighted arithmetic mean.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing "ignoring NaN values".

Suggested change
* Returns an accumulator function which incrementally computes a weighted arithmetic mean.
* Returns an accumulator function which incrementally computes a weighted arithmetic mean, ignoring `NaN` values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file uses 4-space indentation — stdlib convention is 2-space for JSON files.

@Planeshifter Planeshifter added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Mar 10, 2026
@stdlib-bot stdlib-bot removed the Potential Duplicate There might be another pull request resolving the same issue. label Apr 1, 2026
@github-actions github-actions Bot mentioned this pull request Apr 1, 2026
@anandkaranubc

Copy link
Copy Markdown
Contributor

Completed here: #13609

@anandkaranubc anandkaranubc added the autoclose: Already Resolved Pull request which should be auto-closed due proposed changes duplicating already included changes. label Aug 9, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Thank you for working on this pull request. However, we cannot accept your contribution as the issue this pull request seeks to resolve has already been addressed in a different pull request or commit.

Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions.

@stdlib-bot stdlib-bot closed this Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autoclose: Already Resolved Pull request which should be auto-closed due proposed changes duplicating already included changes. Good First PR A pull request resolving a Good First Issue. Needs Changes Pull request which needs changes before being merged. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: add stats/incr/nanwmean

4 participants