Skip to content

refactor: replacing with an array/base/* utility for ndarray/base/unary-strided1d-dispatch #6806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
var join = require( '@stdlib/array/base/join' );
var copy = require( '@stdlib/array/base/copy' );
var everyBy = require( '@stdlib/array/base/every-by' );
var slice = require( '@stdlib/array/base/slice' );
var objectAssign = require( '@stdlib/object/assign' );
var format = require( '@stdlib/string/format' );
var defaults = require( './defaults.json' );
Expand Down Expand Up @@ -73,27 +74,23 @@
}

/**
* Reorders a list of ndarrays such that the output ndarray is the second ndarray argument when passing along to a resolved lower-level strided function.
* Reorders a list of ndarrays such that the output ndarray is the specified index ndarray argument when passing along to a resolved lower-level strided function.
*
* @private
* @param {Array<ndarray>} arrays - list of input ndarrays
* @param {ndarray} output - output ndarray
* @param {NonNegativeInteger} index - specified index
* @returns {Array<ndarray>} reordered list
*/
function reorder( arrays, output ) { // TODO: consider replacing with an `array/base/*` utility which expands an input array by inserting a specified value at a specified index and returns a new array
function reorder( arrays, output, index ) {
var out;
var i;
var j;
var a1;
var a2;

out = [];
for ( i = 0, j = 0; i <= arrays.length; i++ ) {
if ( i === 1 ) {
out.push( output );
} else {
out.push( arrays[ j ] );
j += 1;
}
}
a1 = slice( arrays, 0, index );
a2 = slice( arrays, index, arrays.length - 1 );
out = a1.concat( [ output ], a2 );
return out;
}

Expand Down Expand Up @@ -158,7 +155,7 @@
throw new TypeError( format( 'invalid argument. First argument must be an object having a "types" property whose associated value is an array-like object.' ) );
}
if ( hasProp( table, 'fcns' ) && !isFunctionArray( table.fcns ) && !isEmptyCollection( table.fcns ) ) {
throw new TypeError( format( 'invalid argument. First argument must be an object having a "fcns" property whose associated value is an array-like object containing functions.' ) );

Check warning on line 158 in lib/node_modules/@stdlib/ndarray/base/unary-strided1d-dispatch/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "fcns"
}
if ( !isCollection( idtypes ) ) {
throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', idtypes ) );
Expand Down