You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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.
1054
1052
*
1055
1053
* @private
1056
-
* @param {NonNegativeInteger} N - number of ndarrays in `arrays` to reorder
1057
-
* @param {Array<ndarray>} arrays - list of ndarrays
1054
+
* @param {Array<ndarray>} arrays - list of input ndarrays
1058
1055
* @param {ndarray} output - output ndarray
1059
1056
* @returns {Array<ndarray>} reordered list
1060
1057
*/
1061
-
<spanclass="cstat-no" title="statement not covered" ><spanclass="fstat-no" title="function not covered" >function reorder( N, arrays, output ) {</span></span>
1058
+
<spanclass="cstat-no" title="statement not covered" ><spanclass="fstat-no" title="function not covered" >function reorder( arrays, output ) {</span></span>
1062
1059
<spanclass="cstat-no" title="statement not covered" > var out;</span>
1063
1060
<spanclass="cstat-no" title="statement not covered" > var i;</span>
1064
1061
<spanclass="cstat-no" title="statement not covered" > var j;</span>
1065
1062
<spanclass="cstat-no" title="statement not covered" ></span>
1066
1063
<spanclass="cstat-no" title="statement not covered" > out = [];</span>
1067
-
<spanclass="cstat-no" title="statement not covered" > for ( i = 0, j = 0; i <= N; i++ ) {</span>
1064
+
<spanclass="cstat-no" title="statement not covered" > for ( i = 0, j = 0; i <= arrays.length; i++ ) {</span>
1068
1065
<spanclass="cstat-no" title="statement not covered" > if ( i === 1 ) {</span>
1069
1066
<spanclass="cstat-no" title="statement not covered" > out.push( output );</span>
1070
1067
<spanclass="cstat-no" title="statement not covered" > } else {</span>
<spanclass="cstat-no" title="statement not covered" > else if ( i < nargs-1 ) {</span>
1391
1388
<spanclass="cstat-no" title="statement not covered" > throw new TypeError( format( 'invalid argument. Argument %d must be an ndarray-like object. Value: `%s`.', i, arguments[ i ] ) );</span>
1392
1389
<spanclass="cstat-no" title="statement not covered" > }</span>
1390
+
<spanclass="cstat-no" title="statement not covered" > // Cache a reference to the output ndarray:</span>
1391
+
<spanclass="cstat-no" title="statement not covered" > y = args.pop();</span>
1392
+
<spanclass="cstat-no" title="statement not covered" ></span>
1393
1393
<spanclass="cstat-no" title="statement not covered" > // Verify that additional ndarray arguments have expected dtypes (note: we intentionally don't validate the output ndarray dtype in order to provide an escape hatch for a user wanting to have an output ndarray having a specific dtype that `apply` does not support)...</span>
1394
-
<spanclass="cstat-no" title="statement not covered" > for ( i = 1; i < args.length-1; i++ ) {</span>
1394
+
<spanclass="cstat-no" title="statement not covered" > for ( i = 1; i < args.length; i++ ) {</span>
1395
1395
<spanclass="cstat-no" title="statement not covered" > dt = getDType( args[ i ] );</span>
1396
1396
<spanclass="cstat-no" title="statement not covered" > if ( !contains( this._idtypes[ i ], dt ) ) {</span>
1397
1397
<spanclass="cstat-no" title="statement not covered" > throw new TypeError( format( 'invalid argument. Argument %d must have one of the following data types: "%s". Data type: `%s`.', i, join( this._idtypes[ i ], '", "' ), dt ) );</span>
<spanclass="cstat-no" title="statement not covered" > if ( opts.dims === null ) {</span>
1411
1411
<spanclass="cstat-no" title="statement not covered" > opts.dims = zeroTo( N );</span>
1412
1412
<spanclass="cstat-no" title="statement not covered" > }</span>
1413
-
<spanclass="cstat-no" title="statement not covered" > // Cache a reference to the output ndarray:</span>
1414
-
<spanclass="cstat-no" title="statement not covered" > y = args[ args.length-1 ];</span>
1415
-
<spanclass="cstat-no" title="statement not covered" ></span>
1416
1413
<spanclass="cstat-no" title="statement not covered" > // Resolve the lower-level strided function satisfying the input and output ndarray data types:</span>
1417
1414
<spanclass="cstat-no" title="statement not covered" > dtypes = [ resolveEnum( dt ), resolveEnum( getDType( y ) ) ];</span>
<spanclass="cstat-no" title="statement not covered" > f = this._table.default;</span>
1423
1420
<spanclass="cstat-no" title="statement not covered" > }</span>
1424
1421
<spanclass="cstat-no" title="statement not covered" > // Perform operation:</span>
1425
-
<spanclass="cstat-no" title="statement not covered" > unaryStrided1d( f, reorder( args.length-1, args, y ), opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)</span>
1422
+
<spanclass="cstat-no" title="statement not covered" > unaryStrided1d( 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)</span>
1426
1423
<spanclass="cstat-no" title="statement not covered" ></span>
1427
1424
<spanclass="cstat-no" title="statement not covered" > return y;</span>
0 commit comments