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
shape = copy( shape ); // perform a copy to avoid unintended mutation
477
-
N = shape.length;
487
+
// Copy input arguments to avoid unintended mutation:
488
+
shape = copy( shape );
489
+
idx = copy( dims );
478
490
491
+
// Resolve the shape of the input array:
479
492
sh = getShape( arr, false );
493
+
494
+
N = shape.length;
480
495
M = sh.length;
481
496
if ( N < M ) {
482
497
throw new Error( 'invalid argument. Cannot broadcast an array to a shape having fewer dimensions. Arrays can only be broadcasted to shapes having the same or more dimensions.' );
// Verify that we've been provided a list of unique dimension indices...
488
-
dl = dims.length;
489
-
dims = normalizeIndices( dims, N-1 );
490
-
if ( dims === null ) <spanclass="branch-0 cbranch-no" title="branch not covered" >{</span>
503
+
dl = idx.length;
504
+
idx = normalizeIndices( idx, N-1 );
505
+
if ( idx === null ) <spanclass="branch-0 cbranch-no" title="branch not covered" >{</span>
491
506
<spanclass="cstat-no" title="statement not covered" > throw new RangeError( format( 'invalid argument. Third argument contains an out-of-bounds dimension index. Value: [%s].', join( dims, ',' ) ) );</span>
492
507
<spanclass="cstat-no" title="statement not covered" > }</span>
493
-
dims.sort();
494
-
if ( dims.length !== dl ) <spanclass="branch-0 cbranch-no" title="branch not covered" >{</span>
508
+
idx.sort();
509
+
if ( idx.length !== dl ) <spanclass="branch-0 cbranch-no" title="branch not covered" >{</span>
495
510
<spanclass="cstat-no" title="statement not covered" > throw new Error( format( 'invalid argument. Third argument must contain a list of unique dimension indices. Value: [%s].', join( dims, ',' ) ) );</span>
496
511
<spanclass="cstat-no" title="statement not covered" > }</span>
0 commit comments