feat: add stats/strided/snanmeankbn - #14175
Conversation
Signed-off-by: Aryan Sharma <aryansharma24106@gmail.com>
|
👋 Hi there! 👋 And thank you for opening your first pull request! We will review it shortly. 🏃 💨 Getting Started
Next Steps
Running Tests LocallyYou can use # Run tests for all packages in the math namespace:
make test TESTS_FILTER=".*/@stdlib/math/.*"
# Run benchmarks for a specific package:
make benchmark BENCHMARKS_FILTER=".*/@stdlib/math/base/special/sin/.*"If you haven't heard back from us within two weeks, please ping us by tagging the "reviewers" team in a comment on this PR. If you have any further questions while waiting for a response, please join our Zulip community to chat with project maintainers and other community members. We appreciate your contribution! Documentation Links |
Signed-off-by: Aryan Sharma <aryansharma24106@gmail.com>
This fixes an issue where the native test cases were asserting invalid return values instead of expecting NaNs to be properly ignored, aligning them with the pure JS tests so all tests pass in the C-build. Signed-off-by: Aryan Sharma <aryansharma24106@gmail.com>
0PrashantYadav0
left a comment
There was a problem hiding this comment.
Make all the changes I have suggested.
| */ | ||
| interface Routine { | ||
| /** | ||
| * Computes the arithmetic mean of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm. |
There was a problem hiding this comment.
| * Computes the arithmetic mean of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm. | |
| * Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using an improved Kahan–Babuška algorithm. |
| * @example | ||
| * var Float32Array = require( '@stdlib/array/float32' ); | ||
| * | ||
| * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); |
There was a problem hiding this comment.
| * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); | |
| * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); |
| ( N: number, x: Float32Array, strideX: number ): number; | ||
|
|
||
| /** | ||
| * Computes the arithmetic mean of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm and alternative indexing semantics. |
There was a problem hiding this comment.
| * Computes the arithmetic mean of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm and alternative indexing semantics. | |
| * Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using an improved Kahan–Babuška algorithm and alternative indexing semantics. |
| * @example | ||
| * var Float32Array = require( '@stdlib/array/float32' ); | ||
| * | ||
| * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); |
There was a problem hiding this comment.
| * var x = new Float32Array( [ 1.0, -2.0, 2.0 ] ); | |
| * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); |
| } | ||
|
|
||
| /** | ||
| * Computes the arithmetic mean of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm. |
There was a problem hiding this comment.
| * Computes the arithmetic mean of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm. | |
| * Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using an improved Kahan–Babuška algorithm. |
|
|
||
| ## See Also | ||
|
|
||
| - <span class="package-name">[`@stdlib/stats/strided/dmeankbn`][@stdlib/stats/strided/dmeankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array using an improved Kahan–Babuška algorithm.</span> |
There was a problem hiding this comment.
| - <span class="package-name">[`@stdlib/stats/strided/dmeankbn`][@stdlib/stats/strided/dmeankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array using an improved Kahan–Babuška algorithm.</span> | |
| - <span class="package-name">[`@stdlib/stats/strided/smeankbn`][@stdlib/stats/strided/smeankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm.</span> |
| ## See Also | ||
|
|
||
| - <span class="package-name">[`@stdlib/stats/strided/dmeankbn`][@stdlib/stats/strided/dmeankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array using an improved Kahan–Babuška algorithm.</span> | ||
| - <span class="package-name">[`@stdlib/stats/strided/meankbn`][@stdlib/stats/strided/meankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using an improved Kahan–Babuška algorithm.</span> |
There was a problem hiding this comment.
| - <span class="package-name">[`@stdlib/stats/strided/meankbn`][@stdlib/stats/strided/meankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using an improved Kahan–Babuška algorithm.</span> | |
| - <span class="package-name">[`@stdlib/stats/strided/snanmean`][@stdlib/stats/strided/snanmean]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a single-precision floating-point strided array, ignoring NaN values.</span> |
|
|
||
| - <span class="package-name">[`@stdlib/stats/strided/dmeankbn`][@stdlib/stats/strided/dmeankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array using an improved Kahan–Babuška algorithm.</span> | ||
| - <span class="package-name">[`@stdlib/stats/strided/meankbn`][@stdlib/stats/strided/meankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using an improved Kahan–Babuška algorithm.</span> | ||
| - <span class="package-name">[`@stdlib/stats/strided/smean`][@stdlib/stats/strided/smean]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a single-precision floating-point strided array.</span> |
There was a problem hiding this comment.
| - <span class="package-name">[`@stdlib/stats/strided/smean`][@stdlib/stats/strided/smean]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a single-precision floating-point strided array.</span> | |
| - <span class="package-name">[`@stdlib/stats/strided/snanmeanors`][@stdlib/stats/strided/snanmeanors]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a single-precision floating-point strided array, ignoring NaN values and using ordinary recursive summation.</span> |
|
|
||
| [@stdlib/stats/strided/dmeankbn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/dmeankbn | ||
|
|
||
| [@stdlib/stats/strided/meankbn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/meankbn |
There was a problem hiding this comment.
| [@stdlib/stats/strided/meankbn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/meankbn | |
| [@stdlib/stats/strided/smeankbn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/smeankbn |
|
|
||
| [@stdlib/stats/strided/meankbn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/meankbn | ||
|
|
||
| [@stdlib/stats/strided/smean]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/smean |
There was a problem hiding this comment.
| [@stdlib/stats/strided/smean]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/smean | |
| [@stdlib/stats/strided/snanmean]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/snanmean | |
| [@stdlib/stats/strided/snanmeanors]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/snanmeanors |
0PrashantYadav0
left a comment
There was a problem hiding this comment.
Make all the changes I have suggested.
1e3a746 to
34da390
Compare
|
Thanks for the detailed review @0PrashantYadav0 ! I've addressed all the review feedback across the files, updated the style formatting, and resolved the CI check failures. Local tests and linters are passing cleanly now. It's ready for another look when you have a moment! |
Coverage Report
The above coverage report was generated for the changes in this PR. |
- Update C function signatures and parameter naming according to project conventions - Align header includes and standard type definitions - Fix linting errors and formatting inconsistencies across strided math implementation - Resolve build and test runner CI failures Signed-off-by: Aryan Sharma <aryansharma24106@gmail.com>
34da390 to
421cb9b
Compare
|
Hey! @AryanSharma48 Please take another look at the review—it seems like a couple of the suggested changes slipped through. (I find it helpful to resolve the comments one by one as I apply them so I don't lose track). Also, let's avoid force-pushing. Before you start working on the remaining changes, make sure to pull/fetch the latest updates from your branch. Let me know if you run into any issues! |
Resolves #13955
Description
This pull request:
@stdlib/stats/strided/snanmeankbn, implementing single-precision NaN-ignoring strided mean calculation using Kahan-Babuška-Neumaier (KBN) compensated summation.src/main.candlib/ndarray.jsto perform single-pass sum computation while dynamically filteringNaNvalues and tracking valid count (NaNwhenNaNorndarray, and negative stride behavior.Related Issues
This pull request has the following related issues:
nanmodules forstats/strided#13955Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
I consulted an AI assistant to verify stdlib C header guard conventions, edge cases, and contribution workflows, but the code implementation, stride logic, and test verifications were reviewed and authored manually by myself.
@stdlib-js/reviewers