-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add blas/ext/base/ndarray/dapxsum
#9287
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
base: develop
Are you sure you want to change the base?
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
---
Coverage Report
The above coverage report was generated for the changes in this PR. |
Signed-off-by: piyxsh31 <[email protected]>
|
|
||
| # dapxsum | ||
|
|
||
| > Add a scalar constant to each one-dimensional double-precision floating-point ndarray element and compute the sum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| > Add a scalar constant to each one-dimensional double-precision floating-point ndarray element and compute the sum. | |
| > Add a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum. |
Let's go ahead and make this change to the description here and elsewhere in this PR. I know that you are basing it off of blas/ext/base/dapxsum, but I think the suggested phrasing is a touch better.
| /** | ||
| * Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum. | ||
| * | ||
| * @param arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @param arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant. | |
| * @param arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant |
| * Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum. | ||
| * | ||
| * @param arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant. | ||
| * @returns computed sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @returns computed sum | |
| * @returns sum |
| /** | ||
| * Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum. | ||
| * | ||
| * @param {ArrayLikeObject<Object>} arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @param {ArrayLikeObject<Object>} arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant. | |
| * @param {ArrayLikeObject<Object>} arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant |
| * Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum. | ||
| * | ||
| * @param {ArrayLikeObject<Object>} arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant. | ||
| * @returns {number} computed sum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @returns {number} computed sum | |
| * @returns {number} sum |
| { | ||
| "name": "@stdlib/blas/ext/base/ndarray/dapxsum", | ||
| "version": "0.0.0", | ||
| "description": "Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "description": "Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum.", | |
| "description": "Add a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum.", |
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the function adds a scalar constant to each element and computes the sum', function test( t ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests here are a little too spartan. See other similar base/ndarray packages. You should include tests for non-unit strides, a non-zero offset, negative strides, and what happens when provided an empty ndarray.
| v = dapxsum( [ x, alpha ] ); | ||
|
|
||
| t.strictEqual( v, 16.0, 'returns expected sum' ); | ||
| t.deepEqual( getData( x ), new Float64Array( [ 1.0, -2.0, 2.0 ] ), 'does not mutate input ndarray' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| t.deepEqual( getData( x ), new Float64Array( [ 1.0, -2.0, 2.0 ] ), 'does not mutate input ndarray' ); | |
| t.deepEqual( getData( x ), new Float64Array( [ 1.0, -2.0, 2.0 ] ), 'returns expected value' ); |
|
|
||
| v = dapxsum( [ x, alpha ] ); | ||
|
|
||
| t.strictEqual( v, 16.0, 'returns expected sum' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| t.strictEqual( v, 16.0, 'returns expected sum' ); | |
| t.strictEqual( v, 16.0, 'returns expected value' ); |
kgryte
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this is looking good. Needs some minor clean-up and additional tests.
---
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: 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: passed
- task: lint_license_headers
status: passed
---
|
@kgryte Whenever you have time, could you please take another look? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small documentation edits. Thanks for your PR, which should be ready to go otherwise!
| #### dapxsum( arrays ) | ||
|
|
||
| Computes the sum of a one-dimensional ndarray, ignoring `NaN` values and using a second-order iterative Kahan–Babuška algorithm. | ||
| Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a verb form mismatch here - "Adds" (indicative) followed by "compute" (imperative). Function descriptions should use consistent indicative mood throughout.
| Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum. | |
| Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and computes the sum. |
| Adds a scalar constant to each element of a one-dimensional | ||
| double-precision floating-point ndarray and compute the sum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same verb form issue - "Adds" followed by "compute" should be "computes" for consistency.
| Adds a scalar constant to each element of a one-dimensional | |
| double-precision floating-point ndarray and compute the sum. | |
| Adds a scalar constant to each element of a one-dimensional | |
| double-precision floating-point ndarray and computes the sum. |
| ------- | ||
| out: number | ||
| Sum. | ||
| Computed sum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other ndarray packages (e.g., dsum), the return value description should be just "Sum." rather than "Computed sum."
| Computed sum. | |
| Sum. |
|
|
||
| /** | ||
| * Computes the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. | ||
| * Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verb form mismatch - "compute" should be "computes" for consistency with "Adds".
| * Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum. | |
| * Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and computes the sum. |
|
|
||
| /** | ||
| * Sorts a one-dimensional double-precision floating-point ndarray using Shellsort. | ||
| * Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same verb form issue - should be "computes" to match "Adds".
| * Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum. | |
| * Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and computes the sum. |
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Description
This pull request:
blas/ext/base/ndarray/dapxsumRelated Issues
No.
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
{{TODO: add disclosure if applicable}}
@stdlib-js/reviewers