Skip to content

Commit ea35c4e

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: 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: 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 7007cf4 commit ea35c4e

12 files changed

Lines changed: 444 additions & 530 deletions

File tree

lib/node_modules/@stdlib/blas/ext/join/README.md

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

2121
# join
2222

23-
> Return an [ndarray][@stdlib/ndarray/ctor] created by joining elements using a specified separator along an [ndarray][@stdlib/ndarray/ctor] dimension.
23+
> Return an [ndarray][@stdlib/ndarray/ctor] created by joining elements using a separator along an [ndarray][@stdlib/ndarray/ctor] dimension.
2424
2525
<section class="usage">
2626

@@ -30,9 +30,9 @@ limitations under the License.
3030
var join = require( '@stdlib/blas/ext/join' );
3131
```
3232

33-
#### join( x, separator\[, options] )
33+
#### join( x\[, options] )
3434

35-
Returns an [ndarray][@stdlib/ndarray/ctor] created by joining elements using a specified separator along an [ndarray][@stdlib/ndarray/ctor] dimension.
35+
Returns an [ndarray][@stdlib/ndarray/ctor] created by joining elements using a separator along an [ndarray][@stdlib/ndarray/ctor] dimension.
3636

3737
```javascript
3838
var array = require( '@stdlib/ndarray/array' );
@@ -42,7 +42,7 @@ var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
4242
// returns <ndarray>
4343

4444
// Perform operation:
45-
var out = join( x, ',' );
45+
var out = join( x );
4646
// returns <ndarray>
4747

4848
var v = out.get();
@@ -52,14 +52,31 @@ var v = out.get();
5252
The function has the following parameters:
5353

5454
- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have at least one dimension.
55-
- **separator**: separator. May be either a scalar value or an [ndarray][@stdlib/ndarray/ctor] with generic [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the non-reduced dimensions of the input [ndarray][@stdlib/ndarray/ctor]. For example, given the input shape `[2, 3, 4]` and `options.dim=0`, the separator [ndarray][@stdlib/ndarray/ctor] must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`.
5655
- **options**: function options (_optional_).
5756

5857
The function accepts the following options:
5958

59+
- **separator**: separator. May be either a scalar value or an [ndarray][@stdlib/ndarray/ctor] with generic [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the non-reduced dimensions of the input [ndarray][@stdlib/ndarray/ctor]. For example, given the input shape `[2, 3, 4]` and `options.dim=0`, the separator [ndarray][@stdlib/ndarray/ctor] must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. Default: `,`.
6060
- **dim**: dimension over which to perform operation. If provided a negative integer, the dimension along which to perform the operation is determined by counting backward from the last dimension (where `-1` refers to the last dimension). Default: `-1`.
6161
- **keepdims**: boolean indicating whether the reduced dimensions should be included in the returned [ndarray][@stdlib/ndarray/ctor] as singleton dimensions. Default: `false`.
6262

63+
By default, the function uses `,` as a separator. To perform the operation with a different separator, provide a `separator` option.
64+
65+
```javascript
66+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
67+
var array = require( '@stdlib/ndarray/array' );
68+
69+
var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
70+
71+
var out = join( x, {
72+
'separator': '|'
73+
});
74+
// returns <ndarray>
75+
76+
var v = out.get();
77+
// returns '1|2|3|4|5|6'
78+
```
79+
6380
By default, the function performs the operation over elements in the last dimension. To perform the operation over a different dimension, provide a `dim` option.
6481

6582
```javascript
@@ -68,7 +85,7 @@ var array = require( '@stdlib/ndarray/array' );
6885

6986
var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] );
7087

71-
var out = join( x, ',', {
88+
var out = join( x, {
7289
'dim': 0
7390
});
7491
// returns <ndarray>
@@ -90,16 +107,16 @@ var opts = {
90107
'keepdims': true
91108
};
92109

93-
var out = join( x, ',', opts );
110+
var out = join( x, opts );
94111
// returns <ndarray>
95112

96113
var v = ndarray2array( out );
97114
// returns [ [ '1,3', '2,4' ] ]
98115
```
99116

100-
#### join.assign( x, separator, out\[, options] )
117+
#### join.assign( x, out\[, options] )
101118

102-
Joins elements of an input [ndarray][@stdlib/ndarray/ctor] using a specified separator along an [ndarray][@stdlib/ndarray/ctor] dimension and assigns results to a provided output [ndarray][@stdlib/ndarray/ctor].
119+
Joins elements of an input [ndarray][@stdlib/ndarray/ctor] using a separator along an [ndarray][@stdlib/ndarray/ctor] dimension and assigns results to a provided output [ndarray][@stdlib/ndarray/ctor].
103120

104121
```javascript
105122
var array = require( '@stdlib/ndarray/array' );
@@ -112,7 +129,7 @@ var y = empty( [], {
112129
'dtype': 'generic'
113130
});
114131

115-
var out = join.assign( x, ',', y );
132+
var out = join.assign( x, y );
116133
// returns <ndarray>
117134

118135
var v = out.get();
@@ -125,14 +142,36 @@ var bool = ( out === y );
125142
The method has the following parameters:
126143

127144
- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have at least one dimension.
128-
- **separator**: separator. May be either a scalar value or an [ndarray][@stdlib/ndarray/ctor] with generic [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the non-reduced dimensions of the input [ndarray][@stdlib/ndarray/ctor]. For example, given the input shape `[2, 3, 4]` and `options.dim=0`, the separator [ndarray][@stdlib/ndarray/ctor] must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`.
129145
- **out**: output [ndarray][@stdlib/ndarray/ctor].
130146
- **options**: function options (_optional_).
131147

132148
The method accepts the following options:
133149

150+
- **separator**: separator. May be either a scalar value or an [ndarray][@stdlib/ndarray/ctor] with generic [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the non-reduced dimensions of the input [ndarray][@stdlib/ndarray/ctor]. For example, given the input shape `[2, 3, 4]` and `options.dim=0`, the separator [ndarray][@stdlib/ndarray/ctor] must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`.
134151
- **dim**: dimension over which to perform operation. If provided a negative integer, the dimension along which to perform the operation is determined by counting backward from the last dimension (where `-1` refers to the last dimension). Default: `-1`.
135152

153+
```javascript
154+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
155+
var empty = require( '@stdlib/ndarray/empty' );
156+
var array = require( '@stdlib/ndarray/array' );
157+
158+
var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] );
159+
var y = empty( [ 2 ], {
160+
'dtype': 'generic'
161+
});
162+
163+
var out = join.assign( x, y, {
164+
'dim': 0
165+
});
166+
// returns <ndarray>
167+
168+
var v = ndarray2array( y );
169+
// returns [ '1,3', '2,4' ]
170+
171+
var bool = ( out === y );
172+
// returns true
173+
```
174+
136175
</section>
137176

138177
<!-- /.usage -->
@@ -169,7 +208,7 @@ var x = new ndarray( 'float64', xbuf, [ 5, 2 ], [ 2, 1 ], 0, 'row-major' );
169208
console.log( ndarray2array( x ) );
170209

171210
// Perform operation:
172-
var out = join( x, ',', {
211+
var out = join( x, {
173212
'dim': 0
174213
});
175214

lib/node_modules/@stdlib/blas/ext/join/docs/repl.txt

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

2-
{{alias}}( x, separator[, options] )
3-
Returns an ndarray created by joining elements using a specified separator
4-
along an ndarray dimension.
2+
{{alias}}( x[, options] )
3+
Returns an ndarray created by joining elements using a separator along an
4+
ndarray dimension.
55

66
Parameters
77
----------
88
x: ndarray
99
Input array. Must have at least one dimension.
1010

11-
separator: ndarray|any
11+
options: Object (optional)
12+
Function options.
13+
14+
options.separator: ndarray|any
1215
Separator. May be either a scalar value or an ndarray. If provided
1316
a scalar value, the value is cast to the generic data type. If provided
1417
an ndarray, the value must have a shape which is broadcast compatible
1518
with the non-reduced dimensions of the input ndarray. For example, given
1619
the input shape `[2, 3, 4]` and `options.dim=0`, the separator
1720
ndarray must have a shape which is broadcast-compatible with the shape
18-
`[3, 4]`.
19-
20-
options: Object (optional)
21-
Function options.
21+
`[3, 4]`. Default: `,`.
2222

2323
options.dim: integer (optional)
2424
Dimension over which to perform a reduction. If provided a negative
@@ -38,34 +38,34 @@
3838
Examples
3939
--------
4040
> var x = {{alias:@stdlib/ndarray/array}}( [ 1.0, 2.0, 3.0, 4.0 ] );
41-
> var y = {{alias}}( x, ',' );
41+
> var y = {{alias}}( x );
4242
> var v = y.get()
4343
'1,2,3,4'
4444

4545

46-
{{alias}}.assign( x, separator, out[, options] )
47-
Joins elements of an input ndarray using a specified separator along an
48-
ndarray dimension and assigns results to a provided output ndarray.
46+
{{alias}}.assign( x, out[, options] )
47+
Joins elements of an input ndarray using a separator along an ndarray
48+
dimension and assigns results to a provided output ndarray.
4949

5050
Parameters
5151
----------
5252
x: ndarray
5353
Input array. Must have at least one dimension.
5454

55-
separator: ndarray|any
55+
out: ndarray
56+
Output array.
57+
58+
options: Object (optional)
59+
Function options.
60+
61+
options.separator: ndarray|any
5662
Separator. May be either a scalar value or an ndarray. If provided
5763
a scalar value, the value is cast to the generic data type. If provided
5864
an ndarray, the value must have a shape which is broadcast compatible
5965
with the non-reduced dimensions of the input ndarray. For example, given
6066
the input shape `[2, 3, 4]` and `options.dim=0`, the separator
6167
ndarray must have a shape which is broadcast-compatible with the shape
62-
`[3, 4]`.
63-
64-
out: ndarray
65-
Output array.
66-
67-
options: Object (optional)
68-
Function options.
68+
`[3, 4]`. Default: `,`.
6969

7070
options.dim: integer (optional)
7171
Dimension over which to perform a reduction. If provided a negative
@@ -82,7 +82,7 @@
8282
--------
8383
> var x = {{alias:@stdlib/ndarray/array}}( [ 1.0, 2.0, 3.0, 4.0 ], { 'dtype': 'generic' } );
8484
> var out = {{alias:@stdlib/ndarray/zeros}}( [], { 'dtype': 'generic' } );
85-
> var y = {{alias}}.assign( x, ',', out )
85+
> var y = {{alias}}.assign( x, out )
8686
<ndarray>
8787
> var bool = ( out === y )
8888
true

lib/node_modules/@stdlib/blas/ext/join/docs/types/index.d.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ import { genericndarray, typedndarray } from '@stdlib/types/ndarray';
2727
*/
2828
type InputArray<T> = typedndarray<T>;
2929

30-
/**
31-
* Separator.
32-
*/
33-
type Separator<U> = genericndarray<U> | U;
34-
3530
/**
3631
* Output array.
3732
*/
@@ -54,7 +49,12 @@ interface BaseOptions {
5449
/**
5550
* Interface defining options.
5651
*/
57-
interface Options extends BaseOptions {
52+
interface Options<T> extends BaseOptions {
53+
/**
54+
* Separator. Default: `,`.
55+
*/
56+
separator?: T | genericndarray<T>;
57+
5858
/**
5959
* Boolean indicating whether the reduced dimensions should be included in the returned array as singleton dimensions. Default: `false`.
6060
*/
@@ -67,33 +67,37 @@ interface Options extends BaseOptions {
6767
*/
6868
interface Join {
6969
/**
70-
* Returns an ndarray created by joining elements using a specified separator along an ndarray dimension.
70+
* Returns an ndarray created by joining elements using a separator along an ndarray dimension.
7171
*
7272
* @param x - input ndarray
73-
* @param separator - separator
7473
* @param options - function options
74+
* @param options.separator - separator
75+
* @param options.dim - dimension over which to perform operation
76+
* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions
7577
* @returns output ndarray
7678
*
7779
* @example
7880
* var array = require( '@stdlib/ndarray/array' );
7981
*
8082
* var x = array( [ 1.0, 2.0, 3.0 ] );
8183
*
82-
* var y = join( x, ',' );
84+
* var y = join( x );
8385
* // returns <ndarray>
8486
*
8587
* var idx = y.get();
8688
* // returns '1,2,3'
8789
*/
88-
<T = unknown, U=unknown>( x: InputArray<T>, separator: Separator<U>, options?: Options ): OutputArray<string>;
90+
<T = unknown, U=unknown>( x: InputArray<T>, options?: Options<U> ): OutputArray<string>;
8991

9092
/**
91-
* Joins elements of an input ndarray using a specified separator along an ndarray dimension and assigns results to a provided output ndarray.
93+
* Joins elements of an input ndarray using a separator along an ndarray dimension and assigns results to a provided output ndarray.
9294
*
9395
* @param x - input ndarray
9496
* @param separator - separator
9597
* @param out - output ndarray
9698
* @param options - function options
99+
* @param options.separator - separator
100+
* @param options.dim - dimension over which to perform operation
97101
* @returns output ndarray
98102
*
99103
* @example
@@ -107,7 +111,7 @@ interface Join {
107111
* 'dtype': 'generic'
108112
* });
109113
*
110-
* var out = join.assign( x, ',', y );
114+
* var out = join.assign( x, y );
111115
* // returns <ndarray>
112116
*
113117
* var bool = ( out === y );
@@ -116,14 +120,13 @@ interface Join {
116120
* var idx = out.get();
117121
* // returns '1,2,3'
118122
*/
119-
assign<T = unknown, U = unknown, V extends typedndarray<string> = typedndarray<string>>( x: InputArray<T>, Separator: Separator<U>, out: V, options?: BaseOptions ): V;
123+
assign<T = unknown, U = unknown, V extends typedndarray<string> = typedndarray<string>>( x: InputArray<T>, out: V, options?: Options<U> ): V;
120124
}
121125

122126
/**
123-
* Returns an ndarray created by joining elements using a specified separator along an ndarray dimension.
127+
* Returns an ndarray created by joining elements using a separator along an ndarray dimension.
124128
*
125129
* @param x - input ndarray
126-
* @param separator - separator
127130
* @param options - function options
128131
* @returns output ndarray
129132
*
@@ -132,7 +135,7 @@ interface Join {
132135
*
133136
* var x = array( [ 1.0, 2.0, 3.0 ] );
134137
*
135-
* var y = join( x, ',' );
138+
* var y = join( x );
136139
* // returns <ndarray>
137140
*
138141
* var idx = y.get();
@@ -149,7 +152,7 @@ interface Join {
149152
* 'dtype': 'generic'
150153
* });
151154
*
152-
* var out = join.assign( x, ',', y );
155+
* var out = join.assign( x, y );
153156
* // returns <ndarray>
154157
*
155158
* var bool = ( out === y );

0 commit comments

Comments
 (0)