Skip to content

Commit af7bc58

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: passed - 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 55a3288 commit af7bc58

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ var format = require( '@stdlib/string/format' );
3737
* @param {...*} values - scalar values
3838
* @param {ndarray} out - output ndarray
3939
* @throws {Error} must provide at least three arguments
40-
* @throws {TypeError} first argument must be an ndarray
41-
* @throws {TypeError} first argument must be a one-dimensional ndarray
42-
* @throws {TypeError} output argument must be an ndarray
43-
* @throws {TypeError} output argument must be a one-dimensional ndarray
40+
* @throws {TypeError} first argument must a be one-dimensional ndarray
41+
* @throws {Error} must be provided at least three arguments
42+
* @throws {TypeError} output argument must a be one-dimensional ndarray
4443
* @returns {ndarray} output ndarray
4544
*
4645
* @example
@@ -67,19 +66,16 @@ function assign( x ) {
6766
var out;
6867
var i;
6968

70-
if ( !isndarrayLike( x ) ) {
71-
throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );
72-
}
73-
if ( ndims( x ) !== 1 ) {
69+
if ( !isndarrayLike( x ) || ndims( x ) !== 1 ) {
7470
throw new TypeError( format( 'invalid argument. First argument must be a one-dimensional ndarray. Value: `%s`.', x ) );
7571
}
7672
nargs = arguments.length;
77-
out = arguments[ nargs - 1 ];
78-
if ( !isndarrayLike( out ) ) {
79-
throw new TypeError( format( 'invalid argument. Output argument must be an ndarray. Value: `%s`.', out ) );
73+
if ( nargs < 3 ) {
74+
throw new Error( format( 'invalid argument. The function must be provided at least three arguments. Value: `%s`.', nargs ) );
8075
}
81-
if ( ndims( out ) !== 1 ) {
82-
throw new TypeError( format( 'invalid argument. Output argument must be a one-dimensional ndarray. Value: `%s`.', x ) );
76+
out = arguments[ nargs - 1 ];
77+
if ( !isndarrayLike( out ) || ndims( out ) !== 1 ) {
78+
throw new TypeError( format( 'invalid argument. Output argument must be a one-dimensional ndarray. Value: `%s`.', out ) );
8379
}
8480
dtype = getDType( x );
8581
args = [ x ];

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ var format = require( '@stdlib/string/format' );
3535
*
3636
* @param {ndarray} x - input ndarray
3737
* @param {...*} values - scalar values
38-
* @throws {TypeError} first argument must be an ndarray
39-
* @throws {TypeError} first argument must be a one-dimensional ndarray
38+
* @throws {TypeError} first argument must a be one-dimensional ndarray
39+
* @throws {Error} must be provided at least two arguments
4040
* @returns {ndarray} output ndarray
4141
*
4242
* @example
@@ -57,13 +57,13 @@ function push( x ) {
5757
var args;
5858
var i;
5959

60-
if ( !isndarrayLike( x ) ) {
61-
throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );
62-
}
63-
if ( ndims( x ) !== 1 ) {
60+
if ( !isndarrayLike( x ) | ndims( x ) !== 1 ) {
6461
throw new TypeError( format( 'invalid argument. First argument must be a one-dimensional ndarray. Value: `%s`.', x ) );
6562
}
6663
nargs = arguments.length;
64+
if ( nargs < 2 ) {
65+
throw new Error( format( 'invalid argument. The function must be provided at least two arguments. Value: `%s`.', nargs ) );
66+
}
6767
dtype = getDType( x );
6868
args = [ x ];
6969
for ( i = 1; i < nargs; i++ ) {

lib/node_modules/@stdlib/ndarray/push/test/test.assign.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ tape( 'the function throws an error if provided an output argument which is an n
150150
}
151151
});
152152

153-
tape( 'the function appends the provided provided scalar values and assigns results to an output ndarray (row-major, contiguous)', function test( t ) {
153+
tape( 'the function appends the provided provided scalar values to the input ndarray and assigns results to an output ndarray (row-major, contiguous)', function test( t ) {
154154
var expected;
155155
var actual;
156156
var xbuf;
@@ -178,7 +178,7 @@ tape( 'the function appends the provided provided scalar values and assigns resu
178178
t.end();
179179
});
180180

181-
tape( 'the function appends the provided provided scalar values and assigns results to an output ndarray (column-major, contiguous)', function test( t ) {
181+
tape( 'the function appends the provided provided scalar values to the input ndarray and assigns results to an output ndarray (column-major, contiguous)', function test( t ) {
182182
var expected;
183183
var actual;
184184
var xbuf;
@@ -206,7 +206,7 @@ tape( 'the function appends the provided provided scalar values and assigns resu
206206
t.end();
207207
});
208208

209-
tape( 'the function returns a one-dimensional ndarray formed by appending provided scalar values (row-major, non-contiguous)', function test( t ) {
209+
tape( 'the function appends the provided provided scalar values to the input ndarray and assigns results to an output ndarray (row-major, non-contiguous)', function test( t ) {
210210
var expected;
211211
var actual;
212212
var xbuf;
@@ -234,7 +234,7 @@ tape( 'the function returns a one-dimensional ndarray formed by appending provid
234234
t.end();
235235
});
236236

237-
tape( 'the function returns a one-dimensional ndarray formed by appending provided scalar values (column-major, non-contiguous)', function test( t ) {
237+
tape( 'the function appends the provided provided scalar values to the input ndarray and assigns results to an output ndarray (column-major, non-contiguous)', function test( t ) {
238238
var expected;
239239
var actual;
240240
var xbuf;

0 commit comments

Comments
 (0)