[RFC]: refactor and add protocol support to stats/base/stdevyc
#5686
Labels
Accepted
RFC feature request which has been accepted.
difficulty: 2
May require some initial design or R&D, but should be straightforward to resolve and/or implement.
Feature
Issue or pull request for adding a new feature.
Good First Issue
A good first issue for new contributors!
JavaScript
Issue involves or relates to JavaScript.
priority: Normal
Normal priority concern or feature request.
RFC
Request for comments. Feature requests and proposed changes.
Statistics
Issue or pull request related to statistical functionality.
Description
This RFC proposes refactoring and adding accessor protocol support to
@stdlib/stats/base/stdevyc
.For background on the accessor protocol, see https://blog.stdlib.io/introducing-the-accessor-protocol-for-array-like-objects/.
Examples of what we are looking for:
stats/base/min
: fbb31fb (package)stats/base/cumax
: 11f1341 (package)stats/base/cumin
: 528efd8 (package)stats/base/mediansorted
: 065f865 (package)stats/base/mskmax
: 417e653 (package)While the changes proposed in this RFC will not match the implementations found in the above packages, the packages should provide a conceptual idea of what is desired. Do not simply copy-paste the code found in those packages without reasoning about expected behavior and API design.
Key Points
Refactoring
When refactoring and cleaning up existing implementations, pay special attention to the changes made in the commits referred to above. You'll need to go line-by-line in
@stdlib/stats/base/stdevyc
and compare with the changes made in the above commits.In particular, we're interested in
stats/base
use similar language for describing input parameters and behavior.ndarray
API.Accessor protocol
Prior to adding accessor protocol support, check whether the implementation has any strided array dependencies. For example, for certain algorithms for computing the mean, implementations will depend on algorithms for computing the sum. Ensure that the upstream implementations have support for accessor arrays. If not, you'll need to open a separate PR adding support in the upstream dependencies before working on this package.
When adding support for the accessor protocol, you'll need to do the following:
Create an accessors file
Create a new
lib/accessors.js
file. This file will contain an implementation which can handle accessor arrays.Modify the ndarray file
Modify the
lib/ndarray.js
file to delegate to the accessors implementation when one (or more) of the input arrays is an accessor array.Update tests
Modify the tests to include explicit tests for accessor arrays.
Run tests and other commands
For each of the following commands, please run them from the root stdlib repository directory (not the package folder!).
To run unit tests,
To run examples,
make examples EXAMPLES_FILTER=".*/stats/base/stdevyc/.*"
To run benchmarks,
make benchmark BENCHMARKS_FILTER=".*/stats/base/stdevyc/.*"
Create pull request
Provided all tests, examples, and benchmarks successfully execute and pass and that you've updated the package's documentation, you are now ready to open a pull request!
Notes
Checklist
[RFC]:
.The text was updated successfully, but these errors were encountered: