Skip to content

Commit 997af88

Browse files
committed
refactor: use array utility
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent addcce3 commit 997af88

File tree

1 file changed

+3
-27
lines changed
  • lib/node_modules/@stdlib/ndarray/base/unary-strided1d-dispatch/lib

1 file changed

+3
-27
lines changed

lib/node_modules/@stdlib/ndarray/base/unary-strided1d-dispatch/lib/main.js

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ var empty = require( '@stdlib/ndarray/empty' );
4848
var zeroTo = require( '@stdlib/array/base/zero-to' );
4949
var join = require( '@stdlib/array/base/join' );
5050
var copy = require( '@stdlib/array/base/copy' );
51+
var insertAt = require( '@stdlib/array/base/insert-at' );
5152
var everyBy = require( '@stdlib/array/base/every-by' );
5253
var objectAssign = require( '@stdlib/object/assign' );
5354
var format = require( '@stdlib/string/format' );
@@ -76,31 +77,6 @@ function types2enums( types ) {
7677
return out;
7778
}
7879

79-
/**
80-
* 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.
81-
*
82-
* @private
83-
* @param {Array<ndarray>} arrays - list of input ndarrays
84-
* @param {ndarray} output - output ndarray
85-
* @returns {Array<ndarray>} reordered list
86-
*/
87-
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
88-
var out;
89-
var i;
90-
var j;
91-
92-
out = [];
93-
for ( i = 0, j = 0; i <= arrays.length; i++ ) {
94-
if ( i === 1 ) {
95-
out.push( output );
96-
} else {
97-
out.push( arrays[ j ] );
98-
j += 1;
99-
}
100-
}
101-
return out;
102-
}
103-
10480

10581
// MAIN //
10682

@@ -354,7 +330,7 @@ setReadOnly( UnaryStrided1dDispatch.prototype, 'apply', function apply( x ) {
354330
f = this._table.default;
355331
}
356332
// Perform operation:
357-
this._apply( f, reorder( args, y ), opts.dims );
333+
this._apply( f, insertAt( args, 1, y ), opts.dims );
358334

359335
return y;
360336
});
@@ -502,7 +478,7 @@ setReadOnly( UnaryStrided1dDispatch.prototype, 'assign', function assign( x ) {
502478
f = this._table.default;
503479
}
504480
// Perform operation:
505-
this._apply( f, reorder( args, y ), opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)
481+
this._apply( f, insertAt( args, 1, y ), opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)
506482

507483
return y;
508484
});

0 commit comments

Comments
 (0)