-
-
Notifications
You must be signed in to change notification settings - Fork 990
feat: add stats/base/ndarray/mode
#8622
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 stats/base/ndarray/mode
#8622
Conversation
|
Hello! Thank you for your contribution to stdlib. We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:
This acknowledgment confirms that you've read the guidelines, which include:
We can't review or accept contributions without this acknowledgment. Thank you for your understanding and cooperation. We look forward to reviewing your contribution! |
Coverage Report
The above coverage report was generated for the changes in this PR. |
| * var v = mode( [ x ] ); | ||
| * // returns 2.0 | ||
| */ | ||
| function mode( arrays ) { |
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.
This isn't how we author stats/base/ndarray/* packages. These packages are intended to wrap strided packages and not inline implementations.
Next, you are making various assumptions which may not be appropriate. E.g., you seem to assume numeric elements. What happens if v is a string matching a prototype method of the object you are using as a hash? Furthermore, how should we be handling signed zeros? Here, you treat them as equal. You also return NaN upon encountering a NaN. Is that appropriate? How do other ecosystems (e.g., Python, Julia, R) handle this scenario? You always return the smallest value. Why is that preferred over the largest value? Lastly, you return only a single mode. What if there are multiple modes?
Answering these questions is precisely why we often request opening RFCs in order to first hash out details before moving to implementation.
|
|
||
| # mode | ||
|
|
||
| > Compute the mode of a one-dimensional double-precision floating-point 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.
This description isn't correct if the package name is stats/base/ndarray/mode. You need to spend some time understanding package prefix naming conventions.
| var pow = require( '@stdlib/math/base/special/pow' ); | ||
| var ndarray = require( '@stdlib/ndarray/base/ctor' ); | ||
| var pkg = require( './../package.json' ).name; | ||
| var mode = require( './../lib' ); // renamed |
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.
Please don't leave these sort of AI comments in the codebase. You are just increasing maintainer overhead in having to clean this cruft up.
|
|
||
| return benchmark; | ||
| /** | ||
| * Benchmark function for measuring performance of the `mode` implementation. |
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.
This is an obvious formatting mistake. If you cannot be bothered to go line-by-line reading and cleaning up AI generated code, please don't expect maintainers to bother either. Ditto for the comment at L69.
|
Hello @kgryte, Thank you for your honest feedback. You’re absolutely right — the formatting mistakes and leftover AI artifacts in the PR were careless. I apologize for the addded review burden. I should have throughly reviewed and cleaned the changes lineby-line before submitting. I’m spending more time understanding the codebase and the package nming structure properly, and I will only make a new PR's once the implementation and formatting meet the expected standards. |
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
Resolves None.
Description
This pull request adds a new package:
feat: add stats/base/ndarray/modeThe package provides an implementation for computing the mode of a one-dimensional
ndarraysupporting arbitrary strides, offsets, and negative strides. Includes documentation, benchmarks, examples, test coverage, and REPL help.Checklist
Related Issues
None.
Questions
No questions for reviewers.
Other
No additional notes.
Checklist
AI Assistance
Did you use AI assistance?
No
@stdlib-js/reviewers