Skip to content

Commit 21f8b4a

Browse files
committed
fix: cast to proper dtype
--- 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 ab4baa4 commit 21f8b4a

File tree

1 file changed

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

1 file changed

+20
-14
lines changed

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

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
290290
var xdt;
291291
var ydt;
292292
var zdt;
293+
var dt1;
294+
var dt2;
293295
var dt;
294296
var f;
295297
var N;
@@ -380,20 +382,21 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
380382
});
381383

382384
// Determine whether we need to cast the input ndarray...
383-
dt = binaryInputCastingDataType( xdt, ydt, zdt, this._policies.casting );
384-
if ( xdt !== dt ) {
385+
dt1 = binaryInputCastingDataType( xdt, ydt, zdt, this._policies.casting );
386+
dt2 = binaryInputCastingDataType( ydt, xdt, zdt, this._policies.casting );
387+
if ( xdt !== dt1 ) {
385388
// TODO: replace the following logic with a call to `ndarray/base/(?maybe-)(cast|convert|copy)` or similar utility
386-
tmp = baseEmpty( dt, shx, ordx );
389+
tmp = baseEmpty( dt1, shx, ordx );
387390
assign( [ x, tmp ] );
388391
args[ 0 ] = tmp;
389-
xdt = dt;
392+
xdt = dt1;
390393
}
391-
if ( ydt !== dt ) {
394+
if ( ydt !== dt2 ) {
392395
// TODO: replace the following logic with a call to `ndarray/base/(?maybe-)(cast|convert|copy)` or similar utility
393-
tmp = baseEmpty( dt, shy, ordy );
396+
tmp = baseEmpty( dt2, shy, ordy );
394397
assign( [ y, tmp ] );
395398
args[ 1 ] = tmp;
396-
ydt = dt;
399+
ydt = dt2;
397400
}
398401
// Resolve the lower-level strided function satisfying the input ndarray data type:
399402
dtypes = [ resolveEnum( xdt ), resolveEnum( ydt ) ];
@@ -485,6 +488,8 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'assign', function assign( x, y
485488
var xdt;
486489
var ydt;
487490
var tmp;
491+
var dt1;
492+
var dt2;
488493
var dt;
489494
var N;
490495
var f;
@@ -569,20 +574,21 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'assign', function assign( x, y
569574
opts.dims = zeroTo( N );
570575
}
571576
// Determine whether we need to cast the input ndarray...
572-
dt = binaryInputCastingDataType( xdt, ydt, getDType( z ), this._policies.casting ); // eslint-disable-line max-len
573-
if ( xdt !== dt ) {
577+
dt1 = binaryInputCastingDataType( xdt, ydt, getDType( z ), this._policies.casting ); // eslint-disable-line max-len
578+
dt2 = binaryInputCastingDataType( ydt, xdt, getDType( z ), this._policies.casting ); // eslint-disable-line max-len
579+
if ( xdt !== dt1 ) {
574580
// TODO: replace the following logic with a call to `ndarray/base/(?maybe-)(cast|convert|copy)` or similar utility
575-
tmp = baseEmpty( dt, shx, getOrder( x ) );
581+
tmp = baseEmpty( dt1, shx, getOrder( x ) );
576582
assign( [ x, tmp ] );
577583
args[ 0 ] = tmp;
578-
xdt = dt;
584+
xdt = dt1;
579585
}
580-
if ( ydt !== dt ) {
586+
if ( ydt !== dt2 ) {
581587
// TODO: replace the following logic with a call to `ndarray/base/(?maybe-)(cast|convert|copy)` or similar utility
582-
tmp = baseEmpty( dt, shy, getOrder( y ) );
588+
tmp = baseEmpty( dt2, shy, getOrder( y ) );
583589
assign( [ y, tmp ] );
584590
args[ 1 ] = tmp;
585-
ydt = dt;
591+
ydt = dt2;
586592
}
587593
// Resolve the lower-level strided function satisfying the input ndarray data type:
588594
dtypes = [ resolveEnum( xdt ), resolveEnum( ydt ) ];

0 commit comments

Comments
 (0)