feat: add ndarray/base/full#11017
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
| * var dt = String( getDType( arr ) ); | ||
| * // returns 'float32' | ||
| */ | ||
| function full( dtype, shape, order, value ) { |
There was a problem hiding this comment.
Why does the argument order differ from other packages, such as ndarray/base/broadcast-scalar and ndarray/base/scalar2ndarray? Can you point to another example where we follow your proposed convention?
There was a problem hiding this comment.
I based the argument order on empty and just appended the value argument at the end, but it would likely make more sense to put it at the beginning.
There was a problem hiding this comment.
Done. The argument order is now (value, dtype, shape, order). Since empty uses (dtype, shape, order), I prepended the value argument.
| } | ||
|
|
||
| arr = empty( dtype, shape, order ); | ||
| return fill( arr, value ); |
There was a problem hiding this comment.
It is not clear why we are calling fill here which ends up doing various duplicated logic when we could simply inline the call to broadcastScalar and assign.
There was a problem hiding this comment.
Doing it this way saves you a whole one line of code, which doesn't seem worth it to me, especially when we end up having to re-materialize the input ndarray dtype, shape, and order, which have been specified directly here.
There was a problem hiding this comment.
Done. I left the same TODO comment from the fill function, regarding assign-scalar.
Resolves #{{TODO: add issue number}}.
Description
This pull request:
fullfunction for ndarrays, which creates an ndarray having a specified shape, data type, and filled with a specified value.Related Issues
This pull request has the following related issues:
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