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
throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );
463
431
}
464
432
if ( !isndarrayLike( out ) ) {
465
-
throw new TypeError( format( 'invalid argument. Second argument must be an ndarray-like object having the generic data type. Value: `%s`.', out ) );
433
+
throw new TypeError( format( 'invalid argument. Second argument must be an ndarray-like object. Value: `%s`.', out ) );
466
434
}
467
-
// Resolve input ndarray meta data:
468
-
ord = getOrder( x );
469
-
470
435
// Initialize the separator:
471
436
s = ',';
472
437
473
438
// Initialize an options object:
474
-
opts = {
475
-
'dims': [ -1 ] // default behavior is to perform a reduction over the last dimension
476
-
};
439
+
opts = {};
477
440
478
441
if ( nargs > 2 ) {
479
442
if ( !isPlainObject( options ) ) {
480
443
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
481
444
}
482
445
// Resolve provided options...
483
-
if ( hasOwnProp( options, 'separator' ) ) {
484
-
s = options.separator;
446
+
if ( hasOwnProp( options, 'sep' ) ) {
447
+
s = options.sep;
485
448
}
486
-
if ( hasOwnProp( options, 'dim' ) ) {
487
-
opts.dims[ 0 ] = options.dim;
449
+
if ( hasOwnProp( options, 'dims' ) ) {
450
+
opts.dims= options.dims;
488
451
}
489
452
}
490
-
// Resolve the list of non-reduced dimensions:
491
-
sh = getShape( x );
492
-
if ( sh.length < 1 ) {
493
-
throw new RangeError( 'invalid argument. First argument must have at least one dimension.' );
494
-
}
495
-
sh = nonCoreShape( sh, opts.dims );
496
-
497
453
// Broadcast the separator to match the shape of the non-reduced dimensions...
498
454
if ( isndarrayLike( s ) ) {
499
-
if ( getDType( s ) !== 'generic' ) <spanclass="branch-0 cbranch-no" title="branch not covered" >{</span>
500
-
<spanclass="cstat-no" title="statement not covered" > throw new TypeError( format( 'invalid argument. Second argument must have a generic data type. Value: `%s`.', s ) );</span>
455
+
// When not provided `dims`, the operation is performed across all dimensions and `s` is assumed to be a zero-dimensional ndarray; when `dims` is provided, we need to broadcast `s` to match the shape of the non-core dimensions...
456
+
if ( hasOwnProp( opts, 'dims' ) ) <spanclass="branch-0 cbranch-no" title="branch not covered" >{</span>
457
+
<spanclass="cstat-no" title="statement not covered" > s = maybeBroadcastArray( s, nonCoreShape( getShape( x ), opts.dims ) ); // eslint-disable-line max-len</span>
501
458
<spanclass="cstat-no" title="statement not covered" > }</span>
502
-
s = maybeBroadcastArray( s, sh );
503
459
} else {
504
-
s = broadcastScalar( s, 'generic', sh, ord );
460
+
if ( hasOwnProp( opts, 'dims' ) ) {
461
+
sh = nonCoreShape( getShape( x ), opts.dims );
462
+
} else {
463
+
sh = [];
464
+
}
465
+
s = broadcastScalar( s, 'generic', sh, getOrder( x ) );
* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions
322
320
* @param {*} [options.dtype] - output ndarray data type
323
321
* @throws {TypeError} first argument must be an ndarray-like object
324
-
* @throws {TypeError} second argument must be either an ndarray-like object
322
+
* @throws {TypeError} second argument must be an ndarray-like object
325
323
* @throws {TypeError} options argument must be an object
326
324
* @throws {RangeError} dimension indices must not exceed input ndarray bounds
327
325
* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions
0 commit comments