Skip to content

feat: add stats/base/ndarray/sdsnanmean#9635

Open
aryan7071 wants to merge 8 commits intostdlib-js:developfrom
aryan7071:feat/stats-base-ndarray-sdsnanmean
Open

feat: add stats/base/ndarray/sdsnanmean#9635
aryan7071 wants to merge 8 commits intostdlib-js:developfrom
aryan7071:feat/stats-base-ndarray-sdsnanmean

Conversation

@aryan7071
Copy link
Copy Markdown
Contributor

Description

What is the purpose of this pull request?

This pull request:

  • add stats/base/ndarray/sdsnanmean

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

  • #{{TODO: add related issue number}}

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.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

@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: 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: 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
---
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. labels Jan 8, 2026
@aryan7071
Copy link
Copy Markdown
Contributor Author

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Jan 8, 2026
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Jan 8, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

stdlib-bot commented Jan 8, 2026

Coverage Report

Package Statements Branches Functions Lines
stats/base/ndarray/sdsnanmean $\color{green}101/101$
$\color{green}+0.00%$
$\color{green}3/3$
$\color{green}+0.00%$
$\color{green}1/1$
$\color{green}+0.00%$
$\color{green}101/101$
$\color{green}+0.00%$

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

---
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: passed
  - 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: 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
---
Copy link
Copy Markdown
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

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

Thanks! Looking good.

Comment thread lib/node_modules/@stdlib/stats/base/ndarray/sdsnanmean/lib/main.js Outdated
Comment thread lib/node_modules/@stdlib/stats/base/ndarray/sdsnanmean/lib/main.js Outdated
@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 Jan 10, 2026
---
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: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - 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: passed
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 11, 2026
@Planeshifter Planeshifter changed the title feat: add stats/base/ndarray/sdsnanmean feat: add stats/base/ndarray/sdsnanmean Jan 11, 2026
---
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: 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: na
  - task: lint_javascript_tests
    status: na
  - 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: passed
  - task: lint_license_headers
    status: passed
---
Copy link
Copy Markdown
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

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

Left a bunch of small documentation requests to follow existing conventions more closely.

{
"name": "@stdlib/stats/base/ndarray/sdsnanmean",
"version": "0.0.0",
"description": "Compute the mean of a one-dimensional single-precision floating-point ndarray, 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.

The description should say "arithmetic mean" instead of just "mean" to match the pattern in similar packages like snanmean.

Suggested change
"description": "Compute the mean of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values.",
"description": "Compute the arithmetic mean of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values.",

Comment on lines +57 to +59
"math",
"mean",
"central tendency",
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 a few standard keywords that are present in similar packages (snanmean, dnanmean). Let's add "average", "avg", and "arithmetic mean" to match the established pattern.

Suggested change
"math",
"mean",
"central tendency",
"math",
"average",
"avg",
"mean",
"arithmetic mean",
"central tendency",


# sdsnanmean

> Compute the mean of a one-dimensional single-precision floating-point ndarray, 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 should use the hyperlinked "[arithmetic mean][arithmetic-mean]" format and include the equation section, matching the pattern in snanmean/README.md. The title line should be:

> Compute the [arithmetic mean][arithmetic-mean] of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values.

And you'll also need to add the equation section after line 25 (similar to the one in snanmean/README.md lines 27-41) and the link definition at the end:

[arithmetic-mean]: https://en.wikipedia.org/wiki/Arithmetic_mean


#### sdsnanmean( arrays )

Computes the mean of a one-dimensional single-precision floating-point ndarray, 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 should also use the hyperlinked format to match the reference packages.

Suggested change
Computes the mean of a one-dimensional single-precision floating-point ndarray, ignoring NaN values.
Computes the [arithmetic mean][arithmetic-mean] of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values.

* Computes the arithmetic mean of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values.
*
* @param {ArrayLikeObject<Object>} arrays - array-like object containing an input ndarray
* @returns {number} computed 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.

For consistency with reference packages, the @returns description should use "arithmetic mean" rather than "computed mean".

Suggested change
* @returns {number} computed mean
* @returns {number} arithmetic mean

* Computes the mean of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values.
*
* @param arrays - array-like object containing an input ndarray
* @returns computed 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.

The @returns description should be "arithmetic mean" to match reference packages.

Suggested change
* @returns computed mean
* @returns arithmetic mean

Comment on lines +38 to +39
* var v = sdsnanmean( [ x ] );
* // returns <number>
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.

The example should show the actual expected return value rather than <number>. Looking at the input [ 1.0, 3.0, NaN, 2.0 ], the mean of the non-NaN values (1.0, 3.0, 2.0) is 2.0.

Suggested change
* var v = sdsnanmean( [ x ] );
* // returns <number>
* var v = sdsnanmean( [ x ] );
* // returns 2.0

Comment on lines +2 to +4
{{alias}}( arrays )
Computes the mean of a one-dimensional single-precision floating-point
ndarray, 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 should say "arithmetic mean" to match the pattern in reference packages like snanmean.

Suggested change
{{alias}}( arrays )
Computes the mean of a one-dimensional single-precision floating-point
ndarray, ignoring `NaN` values.
{{alias}}( arrays )
Computes the arithmetic mean of a one-dimensional single-precision floating-
point ndarray, ignoring `NaN` values.

Returns
-------
out: number
Computed 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.

The return description should be "Arithmetic mean." to match the pattern in reference packages.

Suggested change
Computed mean.
Arithmetic mean.


return benchmark;

function benchmark( b ) {
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.

The inner benchmark function is missing its JSDoc documentation. In reference packages like snanmean/benchmark/benchmark.js, this function has a JSDoc block (lines 65-70). Please add:

	/**
	* Benchmark function.
	*
	* @private
	* @param {Benchmark} b - benchmark instance
	*/
	function benchmark( b ) {

@Planeshifter Planeshifter removed the Needs Review A pull request which needs code review. label Feb 14, 2026
---
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: na
  - task: lint_javascript_tests
    status: na
  - 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: passed
  - task: lint_license_headers
    status: passed
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Changes Pull request which needs changes before being merged. Needs Review A pull request which needs code review. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants