From 4b0dbbd3a1a634438fcada35dfc51a265cf9b748 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 22 Aug 2026 14:27:58 +0000 Subject: [PATCH] fix(@stdlib/blas/ext/find-index): supply default `fromIndex` to `gfindIndex` The job "Run JavaScript tests" (run_affected_tests) and the macOS Node.js v16 test job failed on develop with `TypeError: Cannot read properties of undefined (reading 'data')` in `blas/ext/find-index/test/test.assign.js` and `test.main.js`. Root cause: PR #14478 changed `@stdlib/blas/ext/base/ndarray/gfind-index` to require a second, zero-dimensional `fromIndex` ndarray in its `arrays` argument. This package registers `gfindIndex` directly as the `default` entry of a `@stdlib/ndarray/base/unary-reduce-strided1d-dispatch-by-factory` table, and that shared dispatch machinery always invokes table functions with a single-element `arrays` array containing only the input view, so `arrays[1]` was `undefined`. This commit wraps `gfindIndex` in a local `indexOf` function that supplies a constant zero-dimensional `fromIndex` ndarray (value `0`), restoring the pre-#14478 default of searching from the start of the array, without changing the shared dispatch factory or the `gfind-index` kernel. Ref: https://github.com/stdlib-js/stdlib/actions/runs/32550930877 --- .../@stdlib/blas/ext/find-index/lib/base.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/find-index/lib/base.js b/lib/node_modules/@stdlib/blas/ext/find-index/lib/base.js index 7be8c1bf06a8..1afc95e4e658 100644 --- a/lib/node_modules/@stdlib/blas/ext/find-index/lib/base.js +++ b/lib/node_modules/@stdlib/blas/ext/find-index/lib/base.js @@ -21,6 +21,7 @@ // MODULES // var dtypes = require( '@stdlib/ndarray/dtypes' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var gfindIndex = require( '@stdlib/blas/ext/base/ndarray/gfind-index' ); var factory = require( '@stdlib/ndarray/base/unary-reduce-strided1d-dispatch-by-factory' ); @@ -33,8 +34,14 @@ var policies = { 'output': 'integer_index_and_generic', 'casting': 'none' }; + +// Zero-dimensional ndarray specifying the default starting search index expected by `gfindIndex`: +var FROM_INDEX = scalar2ndarray( 0, { + 'dtype': 'generic' +}); + var table = { - 'default': gfindIndex + 'default': indexOf }; @@ -88,6 +95,21 @@ var table = { var findIndex = factory( table, [ idtypes ], odtypes, policies ); +// FUNCTIONS // + +/** +* Invokes `gfindIndex` with a default starting search index. +* +* @private +* @param {ArrayLikeObject} arrays - array-like object containing a one-dimensional input ndarray +* @param {Function} clbk - callback function +* @returns {integer} index +*/ +function indexOf( arrays, clbk ) { + return gfindIndex( [ arrays[ 0 ], FROM_INDEX ], clbk ); +} + + // EXPORTS // module.exports = findIndex;