Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
Signed-off-by: Athan <kgryte@gmail.com>
| // VARIABLES // | ||
|
|
||
| var idtypes = dtypes( 'real_and_generic' ); | ||
| var mdtypes = dtypes( 'integer' ); |
There was a problem hiding this comment.
| var mdtypes = dtypes( 'integer' ); | |
| var mdtypes = dtypes( 'mask_index_and_generic' ); |
There was a problem hiding this comment.
We can be more strict here. Users should be more explicit when working with mask arrays.
| var mdtypes = dtypes( 'integer' ); | ||
| var odtypes = dtypes( 'real_and_generic' ); | ||
| var policies = { | ||
| 'output': 'promoted', |
There was a problem hiding this comment.
This is not correct. We should not be promoting here. A mask array should have no affect on the output dtype.
| The function has the following parameters: | ||
|
|
||
| - **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. | ||
| - **mask**: mask [ndarray][@stdlib/ndarray/ctor]. Must have the same shape as `x`. If a mask element is `0`, the corresponding element in `x` is considered valid. If a mask element is non-zero, the corresponding element in `x` is ignored. |
There was a problem hiding this comment.
This isn't correct. Namely, x and mask should broadcast together. E.g., I should be able to provide a lower-dimensional mask and apply that to each sub-matrix in x. And similarly, I should be able to provide a lower-dimensional x and apply each mask sub-matrix to that same x.
| /** | ||
| * Computes the maximum value along one or more ndarray dimensions according to a mask. | ||
| * | ||
| * @name max |
There was a problem hiding this comment.
| * @name max | |
| * @name mskmax |
| * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); | ||
| * | ||
| * // Create a mask buffer: | ||
| * var mbuf = new Uint8Array( [ 0, 0, 0, 1, 0, 1 ] ); // eslint-disable-line id-length |
There was a problem hiding this comment.
| * var mbuf = new Uint8Array( [ 0, 0, 0, 1, 0, 1 ] ); // eslint-disable-line id-length | |
| * var mbuf = new Uint8Array( [ 0, 0, 0, 1, 0, 1 ] ); |
Don't disable lint rules within JSDoc examples like this.
There was a problem hiding this comment.
Also, this lint rule is not even applicable here.
| * var v = out.get(); | ||
| * // returns 5.0 | ||
| */ | ||
| var mskmax = factory( table, [ idtypes, mdtypes ], odtypes, policies ); |
There was a problem hiding this comment.
Because of broadcast semantics, it isn't enough to simply call factory here. We need a wrapper which handles broadcast semantics.
The package https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/ext/index-of is NOT an apples-to-apples comparison, but it has the same general idea of a "wrapper" around a "base" implementation.
In short, main.js needs to take the input arrays x and mask, call ndarray/base/maybe-broadcast-arrays on them in order to get arrays which are the same shape, and then pass off to the "base" implementation found in base.js.
Same for assign.js, which needs to take the input arrays x and mask and broadcast them together such that they are the same shape.
There was a problem hiding this comment.
Something like
function mskmax( x, mask ) {
if ( !isndarrayLike( x ) {...}
if ( !isndarrayLike( mask ) {....}
arrs = maybeBroadcastArrays( [ x, mask ] );
if ( arguments.length > 2 ) {
return base( arrs[ 0 ], arrs[ 1 ], arguments[ 2 ] );
}
return base( arrs[ 0 ], arrs[ 1 ] );
}There was a problem hiding this comment.
Your current main.js implementation can serve as base.js.
There was a problem hiding this comment.
Obviously this is the first mask package we are doing, so there is a bit more of a learning curve here.
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
|
@iampratik13 You've included changes for |
|
Our development guide includes instructions for how to properly sync branches and remotes. |
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
What is the purpose of this pull request?
This pull request:
feat: add
stats/mskmaxRelated Issues
This pull request has the following related issues:
None
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