Skip to content

Commit 5b2983b

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: passed - 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 1e90d57 commit 5b2983b

File tree

14 files changed

+295
-244
lines changed

14 files changed

+295
-244
lines changed

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

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

2121
# concat1d
2222

23-
> Return a one-dimensional [ndarray][@stdlib/ndarray/ctor] formed by concatenating the provided input arguments.
23+
> Return a one-dimensional [ndarray][@stdlib/ndarray/ctor] formed by concatenating provided input arguments.
2424
2525
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
2626

@@ -42,7 +42,7 @@ var concat1d = require( '@stdlib/ndarray/concat1d' );
4242

4343
#### concat1d( ...arrays )
4444

45-
Returns a one-dimensional [ndarray][@stdlib/ndarray/ctor] formed by concatenating the provided input arguments.
45+
Returns a one-dimensional [ndarray][@stdlib/ndarray/ctor] formed by concatenating provided input arguments.
4646

4747
```javascript
4848
var array = require( '@stdlib/ndarray/array' );
@@ -60,35 +60,9 @@ var arr = ndarray2array( out );
6060

6161
The function accepts the following arguments:
6262

63-
- **...arrays**: inputs to concatenate. May be passed as separate arguments or an array of arguments. Where each argument must either be a one-dimensional [ndarray][@stdlib/ndarray/ctor], a zero-dimensional[ndarray][@stdlib/ndarray/ctor] or a scalar value. The data type of the output [ndarray][@stdlib/ndarray/ctor] is determined by applying [type promotion rules][@stdlib/ndarray/promotion-rules]. If provided scalar inputs or [ndarrays][@stdlib/ndarray/ctor] having different [memory layouts][@stdlib/ndarray/orders], the output [ndarray][@stdlib/ndarray/ctor] has the [default order][@stdlib/ndarray/defaults].
63+
- **...arrays**: inputs to concatenate. May be passed as separate arguments or an array of arguments. Each argument must either be a one-dimensional [ndarray][@stdlib/ndarray/ctor], a zero-dimensional[ndarray][@stdlib/ndarray/ctor], or a scalar value.
6464

65-
The following example demonstrates each invocation style returning equivalent results.
66-
67-
```javascript
68-
var array = require( '@stdlib/ndarray/array' );
69-
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
70-
var ndarray2array = require( '@stdlib/ndarray/to-array' );
71-
72-
var x = array( [ -1.0, 2.0 ] );
73-
var y = scalar2ndarray( -3.0 );
74-
75-
// 1. Using separate arguments:
76-
var out = concat1d( x, y, 4.0 );
77-
// returns <ndarray>
78-
79-
var arr = ndarray2array( out );
80-
// returns [ -1.0, 2.0, -3.0, 4.0 ]
81-
82-
x = array( [ -5.0, 6.0 ] );
83-
y = scalar2ndarray( -7.0 );
84-
85-
// 2. Using an array of arguments:
86-
out = concat1d( [ x, y, 8.0 ] );
87-
// returns <ndarray>
88-
89-
arr = ndarray2array( out );
90-
// returns [ -5.0, 6.0, -7.0, 8.0 ]
91-
```
65+
The data type of the output [ndarray][@stdlib/ndarray/ctor] is determined by applying [type promotion rules][@stdlib/ndarray/promotion-rules]. If provided [ndarrays][@stdlib/ndarray/ctor] having different [memory layouts][@stdlib/ndarray/orders] or only scalar inputs, the output [ndarray][@stdlib/ndarray/ctor] has the [default memory layout][@stdlib/ndarray/defaults].
9266

9367
#### concat1d.assign( ...arrays, out )
9468

@@ -115,46 +89,9 @@ var arr = ndarray2array( z );
11589

11690
The function accepts the following arguments:
11791

118-
- **...arrays**: inputs to concatenate. May be passed as separate arguments or an array of arguments. Where each argument must either be a one-dimensional [ndarray][@stdlib/ndarray/ctor], a zero-dimensional[ndarray][@stdlib/ndarray/ctor] or a scalar value. The data type of the output [ndarray][@stdlib/ndarray/ctor] is determined by applying [type promotion rules][@stdlib/ndarray/promotion-rules]. If provided scalar inputs or [ndarrays][@stdlib/ndarray/ctor] having different [memory layouts][@stdlib/ndarray/orders], the output [ndarray][@stdlib/ndarray/ctor] has the [default order][@stdlib/ndarray/defaults].
92+
- **...arrays**: inputs to concatenate. May be passed as separate arguments or an array of arguments. Each argument must either be a one-dimensional [ndarray][@stdlib/ndarray/ctor], a zero-dimensional[ndarray][@stdlib/ndarray/ctor], or a scalar value.
11993
- **out**: output [ndarray][@stdlib/ndarray/ctor].
12094

121-
The following example demonstrates each invocation style returning equivalent results.
122-
123-
```javascript
124-
var array = require( '@stdlib/ndarray/array' );
125-
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
126-
var zeros = require( '@stdlib/ndarray/zeros' );
127-
var ndarray2array = require( '@stdlib/ndarray/to-array' );
128-
129-
var x = array( [ -1.0, 2.0 ] );
130-
var y = scalar2ndarray( -3.0 );
131-
var z = zeros( [ 4 ] );
132-
133-
// 1. Using separate arguments:
134-
var out = concat1d.assign( x, y, 4.0, z );
135-
// returns <ndarray>
136-
137-
var bool = ( out === z );
138-
// returns true
139-
140-
var arr = ndarray2array( z );
141-
// returns [ -1.0, 2.0, -3.0, 4.0 ]
142-
143-
x = array( [ -5.0, 6.0 ] );
144-
y = scalar2ndarray( -7.0 );
145-
z = zeros( [ 4 ] );
146-
147-
// 2. Using an array of arguments:
148-
out = concat1d.assign( [ x, y, 8.0 ], z );
149-
// returns <ndarray>
150-
151-
bool = ( out === z );
152-
// returns true
153-
154-
arr = ndarray2array( out );
155-
// returns [ -5.0, 6.0, -7.0, 8.0 ]
156-
```
157-
15895
</section>
15996

16097
<!-- /.usage -->
@@ -175,20 +112,17 @@ arr = ndarray2array( out );
175112

176113
```javascript
177114
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
178-
var ndarray = require( '@stdlib/ndarray/ctor' );
115+
var array = require( '@stdlib/ndarray/array' );
179116
var ndarray2array = require( '@stdlib/ndarray/to-array' );
180117
var concat1d = require( '@stdlib/ndarray/concat1d' );
181118

182-
var xbuf = discreteUniform( 6, 0, 10, {
119+
var opts = {
183120
'dtype': 'generic'
184-
});
185-
var x = new ndarray( 'generic', xbuf, [ 6 ], [ 1 ], 0, 'row-major' );
121+
};
122+
var x = array( discreteUniform( 6, 0, 10, opts ), opts );
186123
console.log( ndarray2array( x ) );
187124

188-
var ybuf = discreteUniform( 8, 0, 10, {
189-
'dtype': 'generic'
190-
});
191-
var y = new ndarray( 'generic', ybuf, [ 8 ], [ 1 ], 0, 'row-major' );
125+
var y = array( discreteUniform( 8, 0, 10, opts ), opts );
192126
console.log( ndarray2array( y ) );
193127

194128
var out = concat1d( x, y );

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

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
var bench = require( '@stdlib/bench' );
2424
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
2525
var zeros = require( '@stdlib/ndarray/zeros' );
26+
var zeroTo = require( '@stdlib/array/zero-to' );
27+
var format = require( '@stdlib/string/format' );
2628
var pkg = require( './../package.json' ).name;
2729
var concat1d = require( './../lib/assign.js' );
2830

2931

3032
// MAIN //
3133

32-
bench( pkg+'::ndarrays', function benchmark( b ) {
34+
bench( format( '%s::ndarrays', pkg ), function benchmark( b ) {
3335
var values;
3436
var opts;
3537
var out;
@@ -63,7 +65,7 @@ bench( pkg+'::ndarrays', function benchmark( b ) {
6365
b.end();
6466
});
6567

66-
bench( pkg+'::ndarrays,casting', function benchmark( b ) {
68+
bench( format( '%s::ndarrays,casting', pkg ), function benchmark( b ) {
6769
var values;
6870
var out;
6971
var v;
@@ -96,19 +98,14 @@ bench( pkg+'::ndarrays,casting', function benchmark( b ) {
9698
b.end();
9799
});
98100

99-
bench( pkg+'::scalars', function benchmark( b ) {
101+
bench( format( '%s::scalars', pkg ), function benchmark( b ) {
100102
var values;
101103
var out;
102104
var v;
103105
var i;
104106

105-
values = [
106-
1.0,
107-
2.0,
108-
3.0,
109-
4.0
110-
];
111-
out = zeros( [ 4 ] );
107+
values = zeroTo( 128 );
108+
out = zeros( [ 128 ] );
112109

113110
b.tic();
114111
for ( i = 0; i < b.iterations; i++ ) {
@@ -125,20 +122,16 @@ bench( pkg+'::scalars', function benchmark( b ) {
125122
b.end();
126123
});
127124

128-
bench( pkg+'::ndarrays+scalars', function benchmark( b ) {
125+
bench( format( '%s::ndarrays+scalars', pkg ), function benchmark( b ) {
129126
var values;
130127
var out;
131128
var v;
132129
var i;
133130

134-
values = [
135-
zeros( [ 4 ] ),
136-
1.0,
137-
2.0,
138-
zeros( [ 2 ] ),
139-
4.0
140-
];
141-
out = zeros( [ 9 ] );
131+
values = zeroTo( 122 );
132+
values[ 0 ] = zeros( [ 4 ] );
133+
values[ 3 ] = zeros( [ 2 ] );
134+
out = zeros( [ 128 ] );
142135

143136
b.tic();
144137
for ( i = 0; i < b.iterations; i++ ) {

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
var bench = require( '@stdlib/bench' );
2424
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
2525
var zeros = require( '@stdlib/ndarray/zeros' );
26+
var zeroTo = require( '@stdlib/array/zero-to' );
27+
var format = require( '@stdlib/string/format' );
2628
var pkg = require( './../package.json' ).name;
2729
var concat1d = require( './../lib' );
2830

2931

3032
// MAIN //
3133

32-
bench( pkg+'::ndarrays', function benchmark( b ) {
34+
bench( format( '%s::ndarrays', pkg ), function benchmark( b ) {
3335
var values;
3436
var opts;
3537
var v;
@@ -61,7 +63,7 @@ bench( pkg+'::ndarrays', function benchmark( b ) {
6163
b.end();
6264
});
6365

64-
bench( pkg+'::ndarrays,casting', function benchmark( b ) {
66+
bench( format( '%s::ndarrays,casting', pkg ), function benchmark( b ) {
6567
var values;
6668
var v;
6769
var i;
@@ -92,17 +94,12 @@ bench( pkg+'::ndarrays,casting', function benchmark( b ) {
9294
b.end();
9395
});
9496

95-
bench( pkg+'::scalars', function benchmark( b ) {
97+
bench( format( '%s::scalars', pkg ), function benchmark( b ) {
9698
var values;
9799
var v;
98100
var i;
99101

100-
values = [
101-
1.0,
102-
2.0,
103-
3.0,
104-
4.0
105-
];
102+
values = zeroTo( 128 );
106103

107104
b.tic();
108105
for ( i = 0; i < b.iterations; i++ ) {
@@ -119,18 +116,14 @@ bench( pkg+'::scalars', function benchmark( b ) {
119116
b.end();
120117
});
121118

122-
bench( pkg+'::ndarrays+scalars', function benchmark( b ) {
119+
bench( format( '%s::ndarrays+scalars', pkg ), function benchmark( b ) {
123120
var values;
124121
var v;
125122
var i;
126123

127-
values = [
128-
zeros( [ 4 ] ),
129-
1.0,
130-
2.0,
131-
zeros( [ 2 ] ),
132-
4.0
133-
];
124+
values = zeroTo( 122 );
125+
values[ 0 ] = zeros( [ 4 ] );
126+
values[ 3 ] = zeros( [ 2 ] );
134127

135128
b.tic();
136129
for ( i = 0; i < b.iterations; i++ ) {

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

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

22
{{alias}}( ...arrays )
3-
Returns a one-dimensional ndarray formed by
4-
concatenating the provided inputs.
3+
Returns a one-dimensional ndarray formed by concatenating provided input
4+
arguments.
5+
6+
The data type of the output ndarray is determined by applying type promotion
7+
rules to provided inputs.
8+
9+
If provided ndarrays having different memory layouts or only scalar inputs,
10+
the output ndarray has the default memory layout.
511

612
Parameters
713
----------
8-
arrays: ...ArrayLike|ndarray|any
14+
arrays: ...any|ArrayLike
915
Inputs to concatenate. May be passed as separate arguments or an array
10-
of arguments. Where each argument must either be a one-dimensional
11-
ndarray, a zero-dimensional ndarray or a scalar value. The data type of
12-
the output ndarray is determined by applying type promotion rules. If
13-
provided scalar inputs or ndarrays having different memory layouts, the
14-
output ndarray has the default order.
16+
of arguments. Each argument must either be a one-dimensional ndarray,
17+
a zero-dimensional ndarray, or a scalar value.
1518

1619
Returns
1720
-------
@@ -29,17 +32,15 @@
2932

3033

3134
{{alias}}.assign( ...arrays, out )
32-
Concatenates the provided inputs and assigns results to an output ndarray.
35+
Concatenates provided input arguments and assigns results to an output
36+
ndarray.
3337

3438
Parameters
3539
----------
36-
arrays: ...ArrayLike|ndarray|any
40+
arrays: ...any|ArrayLike
3741
Inputs to concatenate. May be passed as separate arguments or an array
38-
of arguments. Where each argument must either be a one-dimensional
39-
ndarray, a zero-dimensional ndarray or a scalar value. The data type of
40-
the output ndarray is determined by applying type promotion rules. If
41-
provided scalar inputs or ndarrays having different memory layouts, the
42-
output ndarray has the default order.
42+
of arguments. Each argument must either be a one-dimensional ndarray,
43+
a zero-dimensional ndarray, or a scalar value.
4344

4445
out: ndarray
4546
Output ndarray.

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@
2323
import { ArrayLike } from '@stdlib/types/array';
2424
import { typedndarray } from '@stdlib/types/ndarray';
2525

26-
type Input<T=unknown> = typedndarray<T> | number | T;
26+
/**
27+
* Input argument.
28+
*/
29+
type Input<T = unknown> = typedndarray<T> | T;
2730

2831
/**
2932
* Interface describing `concat1d`.
3033
*/
3134
interface Concat1d {
3235
/**
33-
* Returns a one-dimensional ndarray formed by concatenating the provided input arguments.
36+
* Returns a one-dimensional ndarray formed by concatenating provided input arguments.
3437
*
3538
* @param arrays - input arguments
3639
* @returns output ndarray
@@ -48,12 +51,13 @@ interface Concat1d {
4851
* var arr = ndarray2array( out );
4952
* // returns [ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ]
5053
*/
51-
<T = unknown>( arrays: Array<Input<T>> ): typedndarray<T>;
54+
<T = unknown>( arrays: Array<Input<T>> ): typedndarray<T>; // FIXME: this is a tricky one to type correctly, as the actual output dtype depends on type promotion rules
5255

5356
/**
54-
* Returns a one-dimensional ndarray formed by concatenating the provided input arguments.
57+
* Returns a one-dimensional ndarray formed by concatenating provided input arguments.
5558
*
56-
* @param arrays - input arguments
59+
* @param arg - first argument
60+
* @param arrays - remaining input arguments
5761
* @returns output ndarray
5862
*
5963
* @example
@@ -69,7 +73,7 @@ interface Concat1d {
6973
* var arr = ndarray2array( out );
7074
* // returns [ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ]
7175
*/
72-
<T = unknown>( ...arrays: Array<Input<T>> ): typedndarray<T>;
76+
<T = unknown>( arg: Input<T>, ...arrays: Array<Input<T>> ): typedndarray<T>; // FIXME: this is a tricky one to type correctly, as the actual output dtype depends on type promotion rules
7377

7478
/**
7579
* Concatenates provided input arguments and assigns the result to a provided one-dimensional output ndarray.
@@ -101,7 +105,9 @@ interface Concat1d {
101105
/**
102106
* Concatenates provided input arguments and assigns the result to a provided one-dimensional output ndarray.
103107
*
104-
* @param args - input arguments
108+
* @param arg1 - first argument
109+
* @param arg2 - second argument
110+
* @param args - remaining input arguments
105111
* @param out - output ndarray
106112
* @returns output ndarray
107113
*
@@ -123,11 +129,11 @@ interface Concat1d {
123129
* var arr = ndarray2array( z );
124130
* // returns [ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ]
125131
*/
126-
assign<T = unknown, U = unknown, V extends typedndarray<U> = typedndarray<U>>( ...args: Array<Input<T> | V> ): V;
132+
assign<T = unknown, U = unknown, V extends typedndarray<U> = typedndarray<U>>( arg1: Input<T>, arg2: Input<T> | V, ...args: Array<Input<T> | V> ): V; // FIXME: in order to more robustly return a correct output type here, we'd likely need to use overloads with varying arity. The issue here is that `V` needs to be the last argument, which is not captured here.
127133
}
128134

129135
/**
130-
* Returns a one-dimensional ndarray formed by concatenating the provided input arguments.
136+
* Returns a one-dimensional ndarray formed by concatenating provided input arguments.
131137
*
132138
* @param arrays - input arguments
133139
* @returns output ndarray

0 commit comments

Comments
 (0)