Skip to content

Commit aee31ef

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: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - 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 9fb5075 commit aee31ef

File tree

9 files changed

+368
-180
lines changed

9 files changed

+368
-180
lines changed

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

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

2121
# flatten
2222

23-
> Return a flattened copy of an input [`ndarray`][@stdlib/ndarray/ctor].
23+
> Return a flattened copy of an input [ndarray][@stdlib/ndarray/ctor].
2424
2525
<section class="intro">
2626

@@ -38,13 +38,12 @@ var flatten = require( '@stdlib/ndarray/flatten' );
3838

3939
#### flatten( x\[, options] )
4040

41-
Returns a flattened copy of an input [`ndarray`][@stdlib/ndarray/ctor].
41+
Returns a flattened copy of an input [ndarray][@stdlib/ndarray/ctor].
4242

4343
```javascript
4444
var array = require( '@stdlib/ndarray/array' );
4545
var ndarray2array = require( '@stdlib/ndarray/to-array' );
4646

47-
// Create an input ndarray:
4847
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
4948
// returns <ndarray>
5049

@@ -57,27 +56,28 @@ var arr = ndarray2array( y );
5756

5857
The function accepts the following arguments:
5958

60-
- **x**: input [`ndarray`][@stdlib/ndarray/ctor].
59+
- **x**: input [ndarray][@stdlib/ndarray/ctor].
6160
- **options**: function options (_optional_).
6261

6362
The function accepts the following options:
6463

65-
- **depth**: a nonnegative integer specifying the number of input [`ndarray`][@stdlib/ndarray/ctor] dimensions to flatten.
64+
- **order**: order in which input [ndarray][@stdlib/ndarray/ctor] elements should be flattened. Must be one of the following:
6665

67-
- **order**: order of the output [`ndarray`][@stdlib/ndarray/ctor]. May be one of the following:
66+
- `'row-major'`: flatten elements in lexicographic order. For example, given a two-dimensional input [ndarray][@stdlib/ndarray/ctor] (i.e., a matrix), flattening in lexicographic order means flattening the input [ndarray][@stdlib/ndarray/ctor] row-by-row.
67+
- `'column-major'`: flatten elements in colexicographic order. For example, given a two-dimensional input [ndarray][@stdlib/ndarray/ctor] (i.e., a matrix), flattening in colexicographic order means flattening the input [ndarray][@stdlib/ndarray/ctor] column-by-column.
68+
- `'any'`: flatten according to the physical layout of the input [ndarray][@stdlib/ndarray/ctor] data in memory, regardless of the stated [order][@stdlib/ndarray/orders] of the input [ndarray][@stdlib/ndarray/ctor].
69+
- `'same'`: flatten according to the stated [order][@stdlib/ndarray/orders] of the input [ndarray][@stdlib/ndarray/ctor].
6870

69-
- `'row-major'`: the input [`ndarray`][@stdlib/ndarray/ctor] is flattened in lexicographic [order][@stdlib/ndarray/orders].
70-
- `'column-major'`: the input [`ndarray`][@stdlib/ndarray/ctor] is flattened in colexicographic [order][@stdlib/ndarray/orders].
71-
- `'any'`: the input [`ndarray`][@stdlib/ndarray/ctor] is flattened in colexicographic [order][@stdlib/ndarray/orders] if the input [`ndarray`][@stdlib/ndarray/ctor] is column-major; otherwise, it is flattened in lexicographic [order][@stdlib/ndarray/orders].
72-
- `'same'`: the input [`ndarray`][@stdlib/ndarray/ctor] is flattened in the [order][@stdlib/ndarray/orders] of the input [`ndarray`][@stdlib/ndarray/ctor].
71+
Default: `'row-major'`.
7372

74-
By default, all the dimensions of the input [ndarray][@stdlib/ndarray/ctor] are flattened. To flatten to a desired depth, specify the `depth` option.
73+
- **depth**: maximum number of input [ndarray][@stdlib/ndarray/ctor] dimensions to flatten.
74+
75+
By default, the function flattens all dimensions of the input [ndarray][@stdlib/ndarray/ctor]. To flatten to a desired depth, specify the `depth` option.
7576

7677
```javascript
7778
var array = require( '@stdlib/ndarray/array' );
7879
var ndarray2array = require( '@stdlib/ndarray/to-array' );
7980

80-
// Create an input ndarray:
8181
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
8282
// returns <ndarray>
8383

@@ -90,13 +90,12 @@ var arr = ndarray2array( y );
9090
// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
9191
```
9292

93-
By default, the input [ndarray][@stdlib/ndarray/ctor] is flattened in lexicographic order. To flatten in a different [order][@stdlib/ndarray/orders], specify the `order` option.
93+
By default, the input [ndarray][@stdlib/ndarray/ctor] is flattened in lexicographic order. To flatten elements in a different order, specify the `order` option.
9494

9595
```javascript
9696
var array = require( '@stdlib/ndarray/array' );
9797
var ndarray2array = require( '@stdlib/ndarray/to-array' );
9898

99-
// Create an input ndarray:
10099
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
101100
// returns <ndarray>
102101

@@ -115,6 +114,10 @@ var arr = ndarray2array( y );
115114

116115
<section class="notes">
117116

117+
## Notes
118+
119+
- The function **always** returns a copy of input [ndarray][@stdlib/ndarray/ctor] data, even when an input [ndarray][@stdlib/ndarray/ctor] already has the desired number of dimensions.
120+
118121
</section>
119122

120123
<!-- /.notes -->
@@ -135,14 +138,12 @@ var xbuf = discreteUniform( 12, -100, 100, {
135138
'dtype': 'generic'
136139
});
137140

138-
// Create an input ndarray:
139141
var x = array( xbuf, {
140142
'shape': [ 2, 2, 3 ],
141143
'dtype': 'generic'
142144
});
143145
console.log( ndarray2array( x ) );
144146

145-
// Flatten the input ndarray:
146147
var y = flatten( x );
147148
console.log( ndarray2array( y ) );
148149
```

lib/node_modules/@stdlib/ndarray/flatten/benchmark/benchmark.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ bench( pkg+'::2d:row-major', function benchmark( b ) {
3737
var j;
3838

3939
values = [
40-
zeros( 'float64', [ 2, 2 ], 'row-major' ),
41-
zeros( 'float32', [ 2, 2 ], 'row-major' ),
42-
zeros( 'int32', [ 2, 2 ], 'row-major' ),
43-
zeros( 'complex128', [ 2, 2 ], 'row-major' ),
44-
zeros( 'generic', [ 2, 2 ], 'row-major' )
40+
zeros( 'float64', [ 10, 10 ], 'row-major' ),
41+
zeros( 'float32', [ 10, 10 ], 'row-major' ),
42+
zeros( 'int32', [ 10, 10 ], 'row-major' ),
43+
zeros( 'complex128', [ 10, 10 ], 'row-major' ),
44+
zeros( 'generic', [ 10, 10 ], 'row-major' )
4545
];
4646
opts = {
4747
'depth': 1,
@@ -72,11 +72,11 @@ bench( pkg+'::2d:column-major', function benchmark( b ) {
7272
var j;
7373

7474
values = [
75-
zeros( 'float64', [ 2, 2 ], 'row-major' ),
76-
zeros( 'float32', [ 2, 2 ], 'row-major' ),
77-
zeros( 'int32', [ 2, 2 ], 'row-major' ),
78-
zeros( 'complex128', [ 2, 2 ], 'row-major' ),
79-
zeros( 'generic', [ 2, 2 ], 'row-major' )
75+
zeros( 'float64', [ 10, 10 ], 'row-major' ),
76+
zeros( 'float32', [ 10, 10 ], 'row-major' ),
77+
zeros( 'int32', [ 10, 10 ], 'row-major' ),
78+
zeros( 'complex128', [ 10, 10 ], 'row-major' ),
79+
zeros( 'generic', [ 10, 10 ], 'row-major' )
8080
];
8181
opts = {
8282
'depth': 1,
@@ -107,11 +107,11 @@ bench( pkg+'::3d:row-major', function benchmark( b ) {
107107
var j;
108108

109109
values = [
110-
zeros( 'float64', [ 2, 2, 2 ], 'row-major' ),
111-
zeros( 'float32', [ 2, 2, 2 ], 'row-major' ),
112-
zeros( 'int32', [ 2, 2, 2 ], 'row-major' ),
113-
zeros( 'complex128', [ 2, 2, 2 ], 'row-major' ),
114-
zeros( 'generic', [ 2, 2, 2 ], 'row-major' )
110+
zeros( 'float64', [ 2, 5, 10 ], 'row-major' ),
111+
zeros( 'float32', [ 2, 5, 10 ], 'row-major' ),
112+
zeros( 'int32', [ 2, 5, 10 ], 'row-major' ),
113+
zeros( 'complex128', [ 2, 5, 10 ], 'row-major' ),
114+
zeros( 'generic', [ 2, 5, 10 ], 'row-major' )
115115
];
116116
opts = {
117117
'depth': 2,
@@ -142,11 +142,11 @@ bench( pkg+'::3d:column-major', function benchmark( b ) {
142142
var j;
143143

144144
values = [
145-
zeros( 'float64', [ 2, 2, 2 ], 'row-major' ),
146-
zeros( 'float32', [ 2, 2, 2 ], 'row-major' ),
147-
zeros( 'int32', [ 2, 2, 2 ], 'row-major' ),
148-
zeros( 'complex128', [ 2, 2, 2 ], 'row-major' ),
149-
zeros( 'generic', [ 2, 2, 2 ], 'row-major' )
145+
zeros( 'float64', [ 2, 5, 10 ], 'row-major' ),
146+
zeros( 'float32', [ 2, 5, 10 ], 'row-major' ),
147+
zeros( 'int32', [ 2, 5, 10 ], 'row-major' ),
148+
zeros( 'complex128', [ 2, 5, 10 ], 'row-major' ),
149+
zeros( 'generic', [ 2, 5, 10 ], 'row-major' )
150150
];
151151
opts = {
152152
'depth': 2,
@@ -177,11 +177,11 @@ bench( pkg+'::4d:row-major', function benchmark( b ) {
177177
var j;
178178

179179
values = [
180-
zeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ),
181-
zeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ),
182-
zeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ),
183-
zeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ),
184-
zeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' )
180+
zeros( 'float64', [ 2, 5, 2, 5 ], 'row-major' ),
181+
zeros( 'float32', [ 2, 5, 2, 5 ], 'row-major' ),
182+
zeros( 'int32', [ 2, 5, 2, 5 ], 'row-major' ),
183+
zeros( 'complex128', [ 2, 5, 2, 5 ], 'row-major' ),
184+
zeros( 'generic', [ 2, 5, 2, 5 ], 'row-major' )
185185
];
186186
opts = {
187187
'depth': 3,
@@ -212,11 +212,11 @@ bench( pkg+'::4d:column-major', function benchmark( b ) {
212212
var j;
213213

214214
values = [
215-
zeros( 'float64', [ 2, 2, 2, 2 ], 'row-major' ),
216-
zeros( 'float32', [ 2, 2, 2, 2 ], 'row-major' ),
217-
zeros( 'int32', [ 2, 2, 2, 2 ], 'row-major' ),
218-
zeros( 'complex128', [ 2, 2, 2, 2 ], 'row-major' ),
219-
zeros( 'generic', [ 2, 2, 2, 2 ], 'row-major' )
215+
zeros( 'float64', [ 2, 5, 2, 5 ], 'row-major' ),
216+
zeros( 'float32', [ 2, 5, 2, 5 ], 'row-major' ),
217+
zeros( 'int32', [ 2, 5, 2, 5 ], 'row-major' ),
218+
zeros( 'complex128', [ 2, 5, 2, 5 ], 'row-major' ),
219+
zeros( 'generic', [ 2, 5, 2, 5 ], 'row-major' )
220220
];
221221
opts = {
222222
'depth': 3,
@@ -247,11 +247,11 @@ bench( pkg+'::5d:row-major', function benchmark( b ) {
247247
var j;
248248

249249
values = [
250-
zeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ),
251-
zeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
252-
zeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
253-
zeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ),
254-
zeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' )
250+
zeros( 'float64', [ 2, 5, 2, 5, 1 ], 'row-major' ),
251+
zeros( 'float32', [ 2, 5, 2, 5, 1 ], 'row-major' ),
252+
zeros( 'int32', [ 2, 5, 2, 5, 1 ], 'row-major' ),
253+
zeros( 'complex128', [ 2, 5, 2, 5, 1 ], 'row-major' ),
254+
zeros( 'generic', [ 2, 5, 2, 5, 1 ], 'row-major' )
255255
];
256256
opts = {
257257
'depth': 4,
@@ -282,11 +282,11 @@ bench( pkg+'::5d:column-major', function benchmark( b ) {
282282
var j;
283283

284284
values = [
285-
zeros( 'float64', [ 2, 2, 2, 2, 2 ], 'row-major' ),
286-
zeros( 'float32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
287-
zeros( 'int32', [ 2, 2, 2, 2, 2 ], 'row-major' ),
288-
zeros( 'complex128', [ 2, 2, 2, 2, 2 ], 'row-major' ),
289-
zeros( 'generic', [ 2, 2, 2, 2, 2 ], 'row-major' )
285+
zeros( 'float64', [ 2, 5, 2, 5, 1 ], 'row-major' ),
286+
zeros( 'float32', [ 2, 5, 2, 5, 1 ], 'row-major' ),
287+
zeros( 'int32', [ 2, 5, 2, 5, 1 ], 'row-major' ),
288+
zeros( 'complex128', [ 2, 5, 2, 5, 1 ], 'row-major' ),
289+
zeros( 'generic', [ 2, 5, 2, 5, 1 ], 'row-major' )
290290
];
291291
opts = {
292292
'depth': 4,

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
{{alias}}( x[, options] )
33
Returns a flattened copy of an input ndarray.
44

5+
The function always returns a copy of input ndarray data, even when an input
6+
ndarray already has the desired number of dimensions.
7+
58
Parameters
69
----------
710
x: ndarray
@@ -11,10 +14,20 @@
1114
Function options.
1215

1316
options.depth: integer (optional)
14-
Number of dimensions to flatten.
17+
Maximum number of dimensions to flatten. By default, the function
18+
flattens all input ndarray dimensions.
1519

1620
options.order: string (optional)
17-
Order of the output ndarray.
21+
Order in which input ndarray elements should be flattened. The following
22+
orders are supported:
23+
24+
- row-major: flatten in lexicographic order.
25+
- column-major: flatten in colexicographic order.
26+
- same: flatten according to the stated order of the input ndarray.
27+
- any: flatten according to physical layout of the input ndarray data in
28+
memory, regardless of the stated order of the input ndarray.
29+
30+
Default: 'row-major'.
1831

1932
Returns
2033
-------

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

Lines changed: 27 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -20,97 +20,65 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { typedndarray, complexndarray, genericndarray, Order } from '@stdlib/types/ndarray';
23+
import { ndarray, Order } from '@stdlib/types/ndarray';
2424

25+
/**
26+
* Interface defining function options.
27+
*/
2528
interface Options {
2629
/**
27-
* Number of dimensions to flatten.
30+
* Maximum number of dimensions to flatten.
31+
*
32+
* ## Notes
33+
*
34+
* - By default, the function flattens all input ndarray dimensions.
2835
*/
2936
depth?: number;
3037

3138
/**
32-
* Output ndarray order.
39+
* Order in which input ndarray elements should be flattened.
40+
*
41+
* ## Notes
42+
*
43+
* - The following orders are supported:
44+
*
45+
* - **row-major**: flatten in lexicographic order.
46+
* - **column-major**: flatten in colexicographic order.
47+
* - **same**: flatten according to the stated order of the input ndarray.
48+
* - **any**: flatten according to the physical layout of the input ndarray data in memory, regardless of the stated order of the input ndarray.
49+
*
50+
* - Default: 'row-major'.
3351
*/
34-
order?: Order;
52+
order?: Order | 'same' | 'any';
3553
}
3654

3755
/**
3856
* Returns a flattened copy of an input ndarray.
3957
*
40-
* @param x - input ndarray
41-
* @param options - function options
42-
* @param options.depth - number of dimensions to flatten
43-
* @param options.order - order of the output ndarray
44-
* @returns output ndarray
45-
*
46-
* @example
47-
* var array = require( '@stdlib/ndarray/array' );
48-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
49-
*
50-
* // Create an input ndarray:
51-
* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );;
52-
* // return <ndarray>
53-
*
54-
* // Flatten the input ndarray:
55-
* var y = flatten( x );
56-
* // returns <ndarray>
57-
*
58-
* var arr = ndarray2array( y );
59-
* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
60-
*/
61-
declare function flatten( x: complexndarray, options?: Options ): complexndarray;
62-
63-
/**
64-
* Returns a flattened copy of an input ndarray.
65-
*
66-
* @param x - input ndarray
67-
* @param options - function options
68-
* @param options.depth - number of dimensions to flatten
69-
* @param options.order - order of the output ndarray
70-
* @returns output ndarray
58+
* ## Notes
7159
*
72-
* @example
73-
* var array = require( '@stdlib/ndarray/array' );
74-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
75-
*
76-
* // Create an input ndarray:
77-
* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );;
78-
* // return <ndarray>
79-
*
80-
* // Flatten the input ndarray:
81-
* var y = flatten( x );
82-
* // returns <ndarray>
83-
*
84-
* var arr = ndarray2array( y );
85-
* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
86-
*/
87-
declare function flatten<T = unknown>( x: genericndarray<T>, options?: Options ): genericndarray<T>;
88-
89-
/**
90-
* Returns a flattened copy of an input ndarray.
60+
* - The function **always** returns a copy of input ndarray data, even when an input ndarray already has the desired number of dimensions.
9161
*
9262
* @param x - input ndarray
9363
* @param options - function options
94-
* @param options.depth - number of dimensions to flatten
95-
* @param options.order - order of the output ndarray
64+
* @param options.depth - maximum number of dimensions to flatten
65+
* @param options.order - order in which input ndarray elements should be flattened
9666
* @returns output ndarray
9767
*
9868
* @example
9969
* var array = require( '@stdlib/ndarray/array' );
10070
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
10171
*
102-
* // Create an input ndarray:
10372
* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );;
10473
* // return <ndarray>
10574
*
106-
* // Flatten the input ndarray:
10775
* var y = flatten( x );
10876
* // returns <ndarray>
10977
*
11078
* var arr = ndarray2array( y );
11179
* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
11280
*/
113-
declare function flatten<T = unknown>( x: typedndarray<T>, options?: Options ): typedndarray<T>;
81+
declare function flatten<T extends ndarray>( x: T, options?: Options ): T;
11482

11583

11684
// EXPORTS //

0 commit comments

Comments
 (0)