Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add accessor protocol support and refactor stats/base/nanvariancech #6167

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

rahulptl165
Copy link
Contributor

…cech


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: 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 ---

Resolves #5674 .

Description

What is the purpose of this pull request?

This pull request:

  • Adds accessors.js files.
  • Modified lib/nanvariancech.
  • Modified lib/ndarray.js
  • Modified readme, examples, benchmark and docs file.

Related Issues

Does this pull request have any related issues?

This pull request:

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

…cech

---
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: 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
---
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. labels Mar 18, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Mar 18, 2025

Coverage Report

Package Statements Branches Functions Lines
stats/base/nanvariancech $\color{green}366/366$
$\color{green}+100.00\%$
$\color{green}45/45$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}366/366$
$\color{green}+100.00\%$

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

var N = floor( x0.length / 2 );

var v = nanvariancech( N, 1, x1, 2 );
var v = nanvariancech( 4, 1, x1, 2 );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var v = nanvariancech( 4, 1, x1, 2 );
var v = nanvariancech( 5, 1, x1, 2 );


var v = nanvariancech( N, 1, x, 2 );
var v = nanvariancech( 4, 1, x, 2 );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var v = nanvariancech( 4, 1, x, 2 );
var v = nanvariancech( 5, 1, x, 2 );

we should be traversing over the NaN value so that the example can demonstrate how the algorithm deals with it

Computes the variance of a strided array ignoring `NaN` values and using a
one-pass trial mean algorithm.

The `N` and `stride` parameters determine which elements in `x` are accessed
at runtime.
The `N` and stride parameters determine which elements in the strided arrays
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The `N` and stride parameters determine which elements in the strided arrays
The `N` and stride parameters determine which elements in the strided array

there's only 1 array here

@@ -46,31 +46,28 @@
--------
// Standard Usage:
> var x = [ 1.0, -2.0, NaN, 2.0 ];
> {{alias}}( x.length, 1, x, 1 )
> {{alias}}( 4, 1, x, 1 )
~4.3333

// Using `N` and `stride` parameters:
> x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ];
Copy link
Member

Choose a reason for hiding this comment

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

Add a NaN element in the array and traverse over it to show that we're ignoring it

> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> var stride = 2;
> {{alias}}( N, 1, x, stride )
> {{alias}}( 3, 1, x, 2 )
~4.3333

// Using view offsets:
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
Copy link
Member

Choose a reason for hiding this comment

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

similar comment regarding NaN values

buffer, the `offset` parameter supports indexing semantics based on a
starting index.
buffer, the offset parameters support indexing semantics based on a
starting indices.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
starting indices.
starting index.

@@ -108,13 +105,12 @@
--------
// Standard Usage:
> var x = [ 1.0, -2.0, NaN, 2.0 ];
> {{alias}}.ndarray( x.length, 1, x, 1, 0 )
> {{alias}}.ndarray( 4, 1, x, 1, 0 )
~4.3333

// Using offset parameter:
> var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ];
Copy link
Member

Choose a reason for hiding this comment

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

similar comment regarding NaN values

NaN
];

v = nanvariancech( 4, 1, toAccessorArray( x ), 2 );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
v = nanvariancech( 4, 1, toAccessorArray( x ), 2 );
v = nanvariancech( 5, 1, toAccessorArray( x ), 2 );

notice in the comments that the indices which should be traversed are mentioned, kindly follow that

Copy link
Member

Choose a reason for hiding this comment

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

same for all other instances.

@@ -230,15 +352,36 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
NaN
];

N = floor( x.length / 2 );
v = nanvariancech( N, 1, x, 2 );
v = nanvariancech( 4, 1, x, 2 );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
v = nanvariancech( 4, 1, x, 2 );
v = nanvariancech( 5, 1, x, 2 );


v = nanvariancech( N, 1, x1, 2 );
v = nanvariancech( 4, 1, x1, 2 );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
v = nanvariancech( 4, 1, x1, 2 );
v = nanvariancech( 5, 1, x1, 2 );

kindly follow the commented indices, same comment for all other instances

@aayush0325
Copy link
Member

kindly resolve the merge conflicts in readme as well

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

conflicts in README haven't been resolved

@aayush0325
Copy link
Member

kindly match the file structure that we're following, your lib directory should only contain an index.js, main.js, ndarray.js and accessors.js. see #6248 and nanrange/lib for example

@aayush0325 aayush0325 added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Apr 6, 2025
---
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: 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@rahulptl165
Copy link
Contributor Author

rahulptl165 commented Apr 6, 2025

Hi @aayush0325 , I have addressed requested changes. let me know if you want further modification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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]: refactor and add protocol support to stats/base/nanvariancech
3 participants