Skip to content

Commit 1e5c77a

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 351db28 commit 1e5c77a

File tree

1 file changed

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

1 file changed

+3
-27
lines changed

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

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ var takeIndexed = require( '@stdlib/array/base/take-indexed' );
5151
var zeroTo = require( '@stdlib/array/base/zero-to' );
5252
var join = require( '@stdlib/array/base/join' );
5353
var copy = require( '@stdlib/array/base/copy' );
54+
var insertAt = require( '@stdlib/array/base/insert-at' );
5455
var everyBy = require( '@stdlib/array/base/every-by' );
5556
var objectAssign = require( '@stdlib/object/assign' );
5657
var format = require( '@stdlib/string/format' );
@@ -85,31 +86,6 @@ function types2enums( types ) {
8586
return out;
8687
}
8788

88-
/**
89-
* Reorders a list of ndarrays such that the output ndarray is the third ndarray argument when passing along to a resolved lower-level strided function.
90-
*
91-
* @private
92-
* @param {Array<ndarray>} arrays - list of input ndarrays
93-
* @param {ndarray} output - output ndarray
94-
* @returns {Array<ndarray>} reordered list
95-
*/
96-
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
97-
var out;
98-
var i;
99-
var j;
100-
101-
out = [];
102-
for ( i = 0, j = 0; i <= arrays.length; i++ ) {
103-
if ( i === 2 ) {
104-
out.push( output );
105-
} else {
106-
out.push( arrays[ j ] );
107-
j += 1;
108-
}
109-
}
110-
return out;
111-
}
112-
11389

11490
// MAIN //
11591

@@ -407,7 +383,7 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
407383
f = this._table.default;
408384
}
409385
// Perform the reduction:
410-
binaryReduceStrided1d( f, reorder( args, z ), opts.dims );
386+
binaryReduceStrided1d( f, insertAt( args, 2, z ), opts.dims );
411387

412388
// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...
413389
if ( opts.keepdims ) {
@@ -597,7 +573,7 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'assign', function assign( x, y
597573
f = this._table.default;
598574
}
599575
// Perform the reduction:
600-
binaryReduceStrided1d( f, reorder( args, z ), opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)
576+
binaryReduceStrided1d( f, insertAt( args, 2, z ), opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)
601577

602578
return z;
603579
});

0 commit comments

Comments
 (0)