Skip to content

Commit 1e90d57

Browse files
committed
refactor: apply suggestions from code review
--- 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 9fb49a9 commit 1e90d57

File tree

3 files changed

+32
-69
lines changed

3 files changed

+32
-69
lines changed

lib/node_modules/@stdlib/ndarray/concat1d/lib/assign.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ function assign() {
7272
var nargs;
7373
var args;
7474
var arrs;
75+
var isnd;
76+
var dims;
7577
var ord;
7678
var out;
7779
var dt;
@@ -91,26 +93,33 @@ function assign() {
9193
}
9294
}
9395
if ( nargs === 2 ) {
94-
if ( isArrayLikeObject( arguments[ 0 ] ) ) {
96+
if (
97+
isArrayLikeObject( arguments[ 0 ] ) &&
98+
!isndarrayLike( arguments[ 0 ] )
99+
) {
95100
args = arguments[ 0 ];
96101
} else {
97-
args = [];
98-
args.push( arguments[ 0 ] );
102+
args = [ arguments[ 0 ] ];
99103
}
100104
}
101105
out = arguments[ nargs - 1 ];
102106
if ( !isndarrayLike( out ) || ndims( out ) !== 1 ) {
103107
throw new Error( format( 'invalid argument. Output argument must be a one-dimensional ndarray. Value: `%s`.', out ) );
104108
}
105-
// Resolve the `dtype` and `order` of input ndarrays:
109+
isnd = [];
110+
dims = [];
106111
arrs = [];
107112
for ( i = 0; i < args.length; i++ ) {
108-
if ( isndarrayLike( args[ i ] ) ) {
113+
isnd.push( isndarrayLike( args[ i ] ) );
114+
if ( isnd[ i ] ) {
109115
d = ndims( args[ i ] );
110116
if ( d > 1 ) {
111117
throw new RangeError( format( 'invalid argument. The function must be provided a one-dimensional ndarray or a zero-dimensional ndarray. Value: `%s`.', d ) );
112118
}
119+
dims.push( d );
113120
arrs.push( args[ i ] );
121+
} else {
122+
dims.push( -1 );
114123
}
115124
}
116125
if ( arrs.length >= 1 ) {
@@ -122,8 +131,8 @@ function assign() {
122131
}
123132
// Broadcast scalar or 0d ndarray inputs:
124133
for ( i = 0; i < args.length; i++ ) {
125-
if ( isndarrayLike( args[ i ] ) ) {
126-
if ( ndims( args[ i ] ) === 0 ) {
134+
if ( isnd[ i ] ) {
135+
if ( dims[ i ] === 0 ) {
127136
args[ i ] = broadcastArray( args[ i ], [ 1 ] );
128137
}
129138
} else if ( !dt && !ord ) {

lib/node_modules/@stdlib/ndarray/concat1d/lib/main.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ function concat1d() {
6565
var nargs;
6666
var args;
6767
var arrs;
68+
var isnd;
69+
var dims;
6870
var ord;
6971
var dt;
7072
var i;
@@ -83,22 +85,29 @@ function concat1d() {
8385
}
8486
}
8587
if ( nargs === 1 ) {
86-
if ( isArrayLikeObject( arguments[ 0 ] ) ) {
88+
if (
89+
isArrayLikeObject( arguments[ 0 ] ) &&
90+
!isndarrayLike( arguments[ 0 ] )
91+
) {
8792
args = arguments[ 0 ];
8893
} else {
89-
args = [];
90-
args.push( arguments[ 0 ] );
94+
args = [ arguments[ 0 ] ];
9195
}
9296
}
93-
// Resolve the `dtype` and `order` of input ndarrays:
97+
isnd = [];
98+
dims = [];
9499
arrs = [];
95100
for ( i = 0; i < args.length; i++ ) {
96-
if ( isndarrayLike( args[ i ] ) ) {
101+
isnd.push( isndarrayLike( args[ i ] ) );
102+
if ( isnd[ i ] ) {
97103
d = ndims( args[ i ] );
98104
if ( d > 1 ) {
99105
throw new RangeError( format( 'invalid argument. The function must be provided a one-dimensional ndarray or a zero-dimensional ndarray. Value: `%s`.', d ) );
100106
}
107+
dims.push( d );
101108
arrs.push( args[ i ] );
109+
} else {
110+
dims.push( -1 );
102111
}
103112
}
104113
if ( arrs.length >= 1 ) {
@@ -110,8 +119,8 @@ function concat1d() {
110119
}
111120
// Broadcast scalar or 0d ndarray inputs:
112121
for ( i = 0; i < args.length; i++ ) {
113-
if ( isndarrayLike( args[ i ] ) ) {
114-
if ( ndims( args[ i ] ) === 0 ) {
122+
if ( isnd[ i ] ) {
123+
if ( dims[ i ] === 0 ) {
115124
args[ i ] = broadcastArray( args[ i ], [ 1 ] );
116125
}
117126
} else {

lib/node_modules/@stdlib/ndarray/concat1d/lib/normalize_arrays.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)