Skip to content

Commit beef4cd

Browse files
committed
fix: minor bug
1 parent 63c8a0b commit beef4cd

File tree

1 file changed

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

1 file changed

+13
-18
lines changed

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

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ var copy = require( '@stdlib/array/base/copy' );
5454
var everyBy = require( '@stdlib/array/base/every-by' );
5555
var objectAssign = require( '@stdlib/object/assign' );
5656
var format = require( '@stdlib/string/format' );
57+
var defaultSettings = require( '@stdlib/ndarray/defaults' );
5758
var defaults = require( './defaults.json' );
5859
var validate = require( './validate.js' );
5960
var indexOfTypes = require( './index_of_types.js' );
@@ -278,6 +279,7 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
278279
var opts;
279280
var ordx;
280281
var ordy;
282+
var ordz;
281283
var err;
282284
var idx;
283285
var shx;
@@ -294,6 +296,10 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
294296
var z;
295297
var i;
296298
var j;
299+
var o;
300+
301+
// Default ndarray settings:
302+
o = defaultSettings();
297303

298304
nargs = arguments.length;
299305
if ( !isndarrayLike( x ) ) {
@@ -310,13 +316,12 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
310316
if ( !contains( this._idtypes[ 1 ], ydt ) ) {
311317
throw new TypeError( format( 'invalid argument. Second argument must have one of the following data types: "%s". Data type: `%s`.', join( this._idtypes[ 1 ], '", "' ), ydt ) );
312318
}
313-
if ( xdt !== ydt ) {
314-
throw new TypeError( format( 'invalid argument. Both ndarray arguments must be off same data types. But got first ndarray data type "%s", second ndarray data type: `%s`.', xdt, ydt ) );
315-
}
316319
ordx = getOrder( x );
317320
ordy = getOrder( y );
318-
if ( ordx !== ordy ) {
319-
throw new TypeError( format( 'invalid argument. Both ndarray arguments must be off same order. But got first ndarray order "%s", second ndarray order: `%s`.', ordx, ordy ) );
321+
if ( ordx === ordy ) {
322+
ordz = ordx;
323+
} else {
324+
ordz = o.order;
320325
}
321326
args = [ x, y ];
322327
for ( i = 2; i < nargs; i++ ) {
@@ -371,7 +376,7 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
371376
zdt = opts.dtype || binaryOutputDataType( xdt, ydt, this._policies.output );
372377
z = empty( shz, {
373378
'dtype': zdt,
374-
'order': ordx
379+
'order': ordz
375380
});
376381

377382
// Determine whether we need to cast the input ndarray...
@@ -471,8 +476,6 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'assign', function assign( x, y
471476
var dtypes;
472477
var nargs;
473478
var opts;
474-
var ordx;
475-
var ordy;
476479
var args;
477480
var arr;
478481
var err;
@@ -505,14 +508,6 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'assign', function assign( x, y
505508
if ( !contains( this._idtypes[ 1 ], ydt ) ) {
506509
throw new TypeError( format( 'invalid argument. Second argument must have one of the following data types: "%s". Data type: `%s`.', join( this._idtypes[ 1 ], '", "' ), ydt ) );
507510
}
508-
if ( xdt !== ydt ) {
509-
throw new TypeError( format( 'invalid argument. Both ndarray arguments must be off same data types. But got first ndarray data type "%s", second ndarray data type: `%s`.', xdt, ydt ) );
510-
}
511-
ordx = getOrder( x );
512-
ordy = getOrder( y );
513-
if ( ordx !== ordy ) {
514-
throw new TypeError( format( 'invalid argument. Both ndarray arguments must be off same order. But got first ndarray order "%s", second ndarray order: `%s`.', ordx, ordy ) );
515-
}
516511
shx = getShape( x );
517512
shy = getShape( y );
518513

@@ -577,14 +572,14 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'assign', function assign( x, y
577572
dt = binaryInputCastingDataType( xdt, ydt, getDType( z ), this._policies.casting ); // eslint-disable-line max-len
578573
if ( xdt !== dt ) {
579574
// TODO: replace the following logic with a call to `ndarray/base/(?maybe-)(cast|convert|copy)` or similar utility
580-
tmp = baseEmpty( dt, shx, ordx );
575+
tmp = baseEmpty( dt, shx, getOrder( x ) );
581576
assign( [ x, tmp ] );
582577
args[ 0 ] = tmp;
583578
xdt = dt;
584579
}
585580
if ( ydt !== dt ) {
586581
// TODO: replace the following logic with a call to `ndarray/base/(?maybe-)(cast|convert|copy)` or similar utility
587-
tmp = baseEmpty( dt, shy, ordy );
582+
tmp = baseEmpty( dt, shy, getOrder( y ) );
588583
assign( [ y, tmp ] );
589584
args[ 1 ] = tmp;
590585
ydt = dt;

0 commit comments

Comments
 (0)