Skip to content

Commit fd1aff4

Browse files
committed
chore: clean-up
--- 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: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - 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: passed - task: lint_license_headers status: passed ---
1 parent 558f8d1 commit fd1aff4

File tree

8 files changed

+71
-266
lines changed

8 files changed

+71
-266
lines changed

lib/node_modules/@stdlib/ndarray/flatten-from/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# flattenFrom
2222

23-
> Return a copy of an input [ndarray][@stdlib/ndarray/ctor], where all dimensions of the input [ndarray][@stdlib/ndarray/ctor] are flattened starting from a specified dimension.
23+
> Return a copy of an input [ndarray][@stdlib/ndarray/ctor] where all dimensions of the input [ndarray][@stdlib/ndarray/ctor] are flattened starting from a specified dimension.
2424
2525
<section class="intro">
2626

@@ -38,7 +38,7 @@ var flattenFrom = require( '@stdlib/ndarray/flatten-from' );
3838

3939
#### flattenFrom( x, dim\[, options] )
4040

41-
Returns a copy of an input [ndarray][@stdlib/ndarray/ctor], where all dimensions of the input [ndarray][@stdlib/ndarray/ctor] are flattened starting from a specified dimension.
41+
Returns a copy of an input [ndarray][@stdlib/ndarray/ctor] where all dimensions of the input [ndarray][@stdlib/ndarray/ctor] are flattened starting from a specified dimension.
4242

4343
```javascript
4444
var array = require( '@stdlib/ndarray/array' );
@@ -51,12 +51,12 @@ var y = flattenFrom( x, 1 );
5151
// returns <ndarray>
5252

5353
var arr = ndarray2array( y );
54-
// returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
54+
// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
5555
```
5656

5757
The function accepts the following arguments:
5858

59-
- **x**: input [ndarray][@stdlib/ndarray/ctor].
59+
- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have one or more dimensions.
6060
- **dim**: dimension to start flattening from. If provided an integer less than zero, the dimension index is resolved relative to the last dimension, with the last dimension corresponding to the value `-1`.
6161
- **options**: function options (_optional_).
6262

lib/node_modules/@stdlib/ndarray/flatten-from/docs/repl.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11

22
{{alias}}( x, dim[, options] )
3-
Returns a copy of an input ndarray, where all dimensions of the input
4-
ndarray are flattened starting from a specified dimension.
3+
Returns a copy of an input ndarray where all dimensions of the input ndarray
4+
are flattened starting from a specified dimension.
55

66
The function always returns a copy of input ndarray data, even when an input
77
ndarray already has the desired number of dimensions.
88

99
Parameters
1010
----------
1111
x: ndarray
12-
Input ndarray.
12+
Input ndarray. Must have one or more dimensions.
1313

1414
dim: integer
1515
Dimension to start flattening from. If provided an integer less than

lib/node_modules/@stdlib/ndarray/flatten-from/docs/types/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type Options<U> = BaseOptions & {
5454
};
5555

5656
/**
57-
* Returns a copy of an input ndarray, where all dimensions of the input ndarray are flattened starting from a specified dimension.
57+
* Returns a copy of an input ndarray where all dimensions of the input ndarray are flattened starting from a specified dimension.
5858
*
5959
* ## Notes
6060
*
@@ -86,12 +86,12 @@ type Options<U> = BaseOptions & {
8686
* // returns [ 3, 2 ]
8787
*
8888
* var arr = ndarray2array( y );
89-
* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
89+
* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
9090
*/
9191
declare function flattenFrom<T extends ndarray>( x: T, dim: number, options?: BaseOptions ): T;
9292

9393
/**
94-
* Returns a copy of an input ndarray, where all dimensions of the input ndarray are flattened starting from a specified dimension.
94+
* Returns a copy of an input ndarray where all dimensions of the input ndarray are flattened starting from a specified dimension.
9595
*
9696
* ## Notes
9797
*
@@ -122,7 +122,7 @@ declare function flattenFrom<T extends ndarray>( x: T, dim: number, options?: Ba
122122
* // returns [ 3, 2 ]
123123
*
124124
* var arr = ndarray2array( y );
125-
* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
125+
* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
126126
*/
127127
declare function flattenFrom<T = unknown, U extends keyof DataTypeMap<T> = 'generic'>( x: typedndarray<T>, dim: number, options: Options<U> ): DataTypeMap<T>[U];
128128

lib/node_modules/@stdlib/ndarray/flatten-from/docs/types/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ import flattenFrom = require( './index' );
130130
flattenFrom( zeros( 'generic', [ 2, 2, 2 ], 'row-major' ), 0, ( x: number ): number => x ); // $ExpectError
131131
}
132132

133-
// The compiler throws an error if the function is provided a second argument with invalid `order` option...
133+
// The compiler throws an error if the function is provided a second argument with an invalid `order` option...
134134
{
135135
flattenFrom( zeros( 'float64', [ 2, 2, 2 ], 'row-major' ), 0, { 'order': '5' } ); // $ExpectError
136136
flattenFrom( zeros( 'float64', [ 2, 2, 2 ], 'row-major' ), 0, { 'order': true } ); // $ExpectError
@@ -154,7 +154,7 @@ import flattenFrom = require( './index' );
154154
flattenFrom( zeros( 'generic', [ 2, 2, 2 ], 'row-major' ), 0, { 'order': ( x: number ): number => x } ); // $ExpectError
155155
}
156156

157-
// The compiler throws an error if the function is provided a second argument with invalid `dtype` option...
157+
// The compiler throws an error if the function is provided a second argument with an invalid `dtype` option...
158158
{
159159
flattenFrom( zeros( 'float64', [ 2, 2, 2 ], 'row-major' ), 0, { 'dtype': '5' } ); // $ExpectError
160160
flattenFrom( zeros( 'float64', [ 2, 2, 2 ], 'row-major' ), 0, { 'dtype': true } ); // $ExpectError

lib/node_modules/@stdlib/ndarray/flatten-from/lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Return a copy of an input ndarray, where all dimensions of the input ndarray are flattened starting from a specified dimension.
22+
* Return a copy of an input ndarray where all dimensions of the input ndarray are flattened starting from a specified dimension.
2323
*
2424
* @module @stdlib/ndarray/flatten-from
2525
*
@@ -37,7 +37,7 @@
3737
* // returns <ndarray>
3838
*
3939
* var arr = ndarray2array( y );
40-
* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
40+
* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
4141
*/
4242

4343
// MODULES //

lib/node_modules/@stdlib/ndarray/flatten-from/lib/main.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ var COL_MAJOR = 'column-major';
4848
// MAIN //
4949

5050
/**
51-
* Returns a copy of an input ndarray, where all dimensions of the input ndarray are flattened starting from a specified dimension.
51+
* Returns a copy of an input ndarray where all dimensions of the input ndarray are flattened starting from a specified dimension.
5252
*
5353
* @param {ndarray} x - input ndarray
54-
* @param {integer} dim - dimension to start flattening from.
54+
* @param {integer} dim - dimension to start flattening from
5555
* @param {Options} [options] - function options
5656
* @param {string} [options.order='row-major'] - order in which input ndarray elements should be flattened
5757
* @param {*} [options.dtype] - output ndarray data type
58-
* @throws {TypeError} first argument must be an ndarray-like object
58+
* @throws {TypeError} first argument must be an ndarray having one or more dimensions
5959
* @throws {TypeError} second argument must be an integer
6060
* @throws {TypeError} options argument must be an object
6161
* @throws {TypeError} must provide valid options
@@ -72,7 +72,7 @@ var COL_MAJOR = 'column-major';
7272
* // returns <ndarray>
7373
*
7474
* var arr = ndarray2array( y );
75-
* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
75+
* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
7676
*
7777
* @example
7878
* var array = require( '@stdlib/ndarray/array' );
@@ -282,7 +282,6 @@ var COL_MAJOR = 'column-major';
282282
* // returns [ 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ]
283283
*/
284284
function flattenFrom( x, dim, options ) {
285-
var nargs;
286285
var view;
287286
var opts;
288287
var xsh;
@@ -291,22 +290,23 @@ function flattenFrom( x, dim, options ) {
291290
var y;
292291

293292
if ( !isndarrayLike( x ) ) {
294-
throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );
293+
throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );
295294
}
296295
if ( !isInteger( dim ) ) {
297296
throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', dim ) );
298297
}
299-
nargs = arguments.length;
300298
xsh = getShape( x );
301-
299+
if ( xsh.length < 1 ) {
300+
throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', xsh.length ) );
301+
}
302302
// Define default options:
303303
opts = {
304304
'order': ROW_MAJOR, // by default, flatten in lexicographic order (i.e., trailing dimensions first; e.g., if `x` is a matrix, flatten row-by-row)
305305
'dtype': getDType( x )
306306
};
307307

308308
// Resolve function options...
309-
if ( nargs > 2 ) {
309+
if ( arguments.length > 2 ) {
310310
if ( !isPlainObject( options ) ) {
311311
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
312312
}
@@ -341,12 +341,12 @@ function flattenFrom( x, dim, options ) {
341341
}
342342
// Create an output ndarray having contiguous memory:
343343
y = emptyLike( x, {
344-
'shape': flattenShapeFrom( xsh, dim ),
344+
'shape': flattenShapeFrom( xsh, dim ), // note: delegate to `flattenShapeFrom` to handle `dim` normalization
345345
'order': opts.order,
346346
'dtype': opts.dtype
347347
});
348348

349-
// Create a view on top of output ndarray having the same shape as the input ndarray:
349+
// Create a view on top of the output ndarray having the same shape as the input ndarray:
350350
st = ( xsh.length > 0 ) ? shape2strides( xsh, opts.order ) : [ 0 ];
351351
view = ndarray( opts.dtype, getData( y ), xsh, st, 0, opts.order );
352352

lib/node_modules/@stdlib/ndarray/flatten-from/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stdlib/ndarray/flatten-from",
33
"version": "0.0.0",
4-
"description": "Return a copy of an input ndarray, where all dimensions of the input ndarray are flattened starting from a specified dimension.",
4+
"description": "Return a copy of an input ndarray where all dimensions of the input ndarray are flattened starting from a specified dimension.",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",

0 commit comments

Comments
 (0)