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 C ndarray interface and refactor implementation for stats/base/dnanmeanpw #4763

Merged
merged 21 commits into from
Jan 19, 2025

Conversation

aayush0325
Copy link
Member

Description

What is the purpose of this pull request?

This pull request:

  • adds C ndarray interface for stats/base/dnanmeanpw
  • refactors JavaScript implementation
  • updates tests, docs, examples and benchmarks

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: 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: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: passed
  - 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 Jan 15, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jan 15, 2025

Coverage Report

Package Statements Branches Functions Lines
stats/base/dnanmeanpw $\color{green}354/354$
$\color{green}+100.00\%$
$\color{green}13/13$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}354/354$
$\color{green}+100.00\%$

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

Copy link
Member

@headlessNode headlessNode left a comment

Choose a reason for hiding this comment

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

The pointer should be CBLAS_INT type here.

See: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/%40stdlib/blas/ext/base/dnannsumpw/README.md?plain=1#L242

EDIT: Looks like the JavaScript also needs to refactored.

lib/node_modules/@stdlib/stats/base/dnanmeanpw/src/main.c Outdated Show resolved Hide resolved
lib/node_modules/@stdlib/stats/base/dnanmeanpw/src/main.c Outdated Show resolved Hide resolved
@aayush0325 aayush0325 marked this pull request as draft January 15, 2025 14:34
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jan 15, 2025
@aayush0325
Copy link
Member Author

EDIT: Looks like the JavaScript also needs to refactored.

yes, i'm aware of that. i forgot to mark this as a draft 😅

aayush0325 and others added 2 commits January 15, 2025 20:08
---
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: 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
---

---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: na
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: na
  - task: run_c_benchmarks
    status: na
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: na
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: failed
---
---
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: 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
---
---
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: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: passed
  - task: lint_c_benchmarks
    status: passed
  - 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: 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: na
  - 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: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@aayush0325 aayush0325 marked this pull request as ready for review January 17, 2025 10:24
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 17, 2025
Copy link
Member

@headlessNode headlessNode left a comment

Choose a reason for hiding this comment

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

@aayush0325 A few documentation related suggestions.

1 - Use consistent terminology across similar packages and within the files of a single package. Notice that some files in this package use "stride length" and "starting index" instead of "stride length for x" and "starting index for x"

2 - For cases with multiple input arrays, we can then use specific terms like "stride length for x" and "stride length for y" to maintain clarity.

cc @kgryte

lib/node_modules/@stdlib/stats/base/dnanmeanpw/README.md Outdated Show resolved Hide resolved
lib/node_modules/@stdlib/stats/base/dnanmeanpw/README.md Outdated Show resolved Hide resolved
lib/node_modules/@stdlib/stats/base/dnanmeanpw/README.md Outdated Show resolved Hide resolved
lib/node_modules/@stdlib/stats/base/dnanmeanpw/README.md Outdated Show resolved Hide resolved
lib/node_modules/@stdlib/stats/base/dnanmeanpw/README.md Outdated Show resolved Hide resolved
lib/node_modules/@stdlib/stats/base/dnanmeanpw/README.md Outdated Show resolved Hide resolved
lib/node_modules/@stdlib/stats/base/dnanmeanpw/src/main.c Outdated Show resolved Hide resolved
@aayush0325
Copy link
Member Author

@aayush0325 A few documentation related suggestions

That makes a lot of sense. We'd have to update the documentation for the existing packages as well. Dropping a patch soon!

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Jan 17, 2025
@aayush0325 aayush0325 requested a review from kgryte January 18, 2025 16:24
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 18, 2025
@aayush0325 aayush0325 marked this pull request as draft January 18, 2025 16:28
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jan 18, 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: 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@aayush0325 aayush0325 marked this pull request as ready for review January 19, 2025 00:08
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 19, 2025
@aayush0325
Copy link
Member Author

aayush0325 commented Jan 19, 2025

kindly take a look at the examples here, we'd have to update this in existing packages as well, dropping a patch for that soon!

@kgryte
Copy link
Member

kgryte commented Jan 19, 2025

@aayush0325 README examples LGTM

@kgryte kgryte removed the Needs Changes Pull request which needs changes before being merged. label Jan 19, 2025
@aayush0325
Copy link
Member Author

@aayush0325 README examples LGTM

few other places where we had to make similar changes as well, see this commit, i will then make similar changes across existing packages

@kgryte
Copy link
Member

kgryte commented Jan 19, 2025

few other places where we had to make similar changes as well

Those look fine to me, as well.

dnansumpw( N, WORKSPACE, x, stride, offset );
return WORKSPACE[ 0 ] / WORKSPACE[ 1 ];
function dnanmeanpw( N, x, strideX, offsetX ) {
var out = new Float64Array( 2 );
Copy link
Member

Choose a reason for hiding this comment

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

@aayush0325 The WORKSPACE idea is still valid here. Namely, we can avoid allocating a new out array for each call to dnanmeanpw and just reuse the same workspace each time. While not thread safe in C, this is perfectly fine in JS.

Copy link
Member Author

Choose a reason for hiding this comment

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

i'll keep this in mind!

Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

LGTM

@kgryte kgryte added Feature Issue or pull request for adding a new feature. C Issue involves or relates to C. and removed Needs Review A pull request which needs code review. labels Jan 19, 2025
@kgryte kgryte merged commit be4a2ee into stdlib-js:develop Jan 19, 2025
43 checks passed
@aayush0325 aayush0325 deleted the ndarray-dnanmeanpw branch January 20, 2025 02:41
Neerajpathak07 pushed a commit to Neerajpathak07/stdlib that referenced this pull request Jan 23, 2025
…base/dnanmeanpw`

PR-URL: stdlib-js#4763
Co-authored-by: Athan Reines <[email protected]>
Co-authored-by: Muhammad Haris <[email protected]>
Reviewed-by: Athan Reines <[email protected]> 
Reviewed-by: Muhammad Haris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Issue involves or relates to C. Feature Issue or pull request for adding a new feature. Statistics Issue or pull request related to statistical functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants