feat: add fromIndex support to blas/ext/base/ndarray/gfind-last-index - #14479
feat: add fromIndex support to blas/ext/base/ndarray/gfind-last-index#14479headlessNode wants to merge 1 commit into
fromIndex support to blas/ext/base/ndarray/gfind-last-index#14479Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
The test failure is from top-level |
|
Do we want |
|
...that said, it is not clear why the standard bodies did not include |
|
Update: did a bit of digging. function predicate( v, i ) {
if ( i < fromIndex ) {
return false;
}
// ...
}This also made it consistent with the other callback-based APIs (e.g., there is no I do, however, think there is an argument that we should add support for a Furthermore, if we support a TL;DR: I am on board with adding |
| 'dtype': 'generic' | ||
| }); | ||
| actual = gfindLastIndex( [ x, fromIndex ], isEven ); | ||
| t.strictEqual( actual, 0, 'returns expected value' ); |
There was a problem hiding this comment.
This doesn't seem correct. If I provide -7 for a six element array, I have exceeded the beginning of the array. But here, you are clamping to 0, resulting in a valid return value; however, we should be returning -1.
This ensures parity with gfind-index. There, if a positive fromIndex exceeds the array bounds, we always return -1. We should behave similarly here.
This is likely going to apply to all the "last" packages you have recently refactored and will need further correction.
Accordingly, this brings me back to ndarray/base/clip-upper-index, where the lower bound is not clamped. Your logic in the wrapper would then need to change such that if the returned value is less than zero, you return -1.
|
|
||
| N = numelDimension( x, 0 ); | ||
| fromIndex = clipIndex( fromIndex, N ); | ||
| if ( fromIndex >= N ) { |
There was a problem hiding this comment.
Why is this check necessary? Instead, for L75, you should use N-1. Then, you don't need to explicitly set to N-1. This is going to apply to your other "last" refactorings and should be addressed in a follow-up PR for those packages.
Resolves stdlib-js/metr-issue-tracker#1183.
Description
This pull request:
fromIndexsupport toblas/ext/base/ndarray/gfind-last-indexRelated Issues
This pull request has the following related issues:
fromIndexparameter support toblas/ext/base/ndarray/gfind-last-indexmetr-issue-tracker#1183.Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
Primarily written by Claude Code.
@stdlib-js/reviewers