Skip to content

Commit 6dab75c

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: na - 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: skipped - task: lint_license_headers status: passed ---
1 parent 2393e1a commit 6dab75c

10 files changed

Lines changed: 391 additions & 68 deletions

File tree

lib/node_modules/@stdlib/blas/ext/base/gediff/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ The function has the following parameters:
5353
- **N**: number of indexed elements.
5454
- **x**: input array.
5555
- **strideX**: stride length for `x`.
56-
- **N1**: number of elements to `prepend`.
57-
- **prepend**: array containing values to prepend to the output array.
56+
- **N1**: number of indexed elements to `prepend`.
57+
- **prepend**: array containing values to prepend after computing differences.
5858
- **strideP**: stride length for `prepend`.
59-
- **N2**: number of elements to `append`.
60-
- **append**: array containing values to append to the output array.
59+
- **N2**: number of indexed elements to `append`.
60+
- **append**: array containing values to append after computing differences.
6161
- **strideA**: stride length for `append`.
6262
- **out**: output array. Must have `N + N1 + N2 - 1` elements.
6363
- **strideOut**: stride length for `out`.
@@ -144,7 +144,7 @@ console.log( out );
144144

145145
## Notes
146146

147-
- If the sum of `N`, `N1`, and `N2` is less than or equal to `1`, both functions return the output array unchanged.
147+
- If `N + N1 + N2 <= 1`, both functions return the output array unchanged.
148148

149149
</section>
150150

@@ -179,7 +179,7 @@ console.log( 'Append array: ', a );
179179
var out = zeros( 13 );
180180

181181
gediff( x.length, x, 1, 2, p, 1, 2, a, 1, out, 1 );
182-
console.log( 'Output', out );
182+
console.log( 'Output: ', out );
183183
```
184184

185185
</section>
Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
{{alias}}( N, x, sx, N1, p, sp, N2, a, sa, out, so )
2+
{{alias}}( N, x,sx, N1, p,sp, N2, a,sa, out,so )
33
Calculates the differences between consecutive elements of a strided array.
44

55
The `N` and stride parameters determine which elements in the strided arrays
@@ -8,52 +8,51 @@
88
Indexing is relative to the first index. To introduce an offset, use a typed
99
array view.
1010

11-
If the sum of `N`, `N1`, and `N2` is less than or equal to `1`, the function
12-
returns the output array unchanged.
11+
If `N + N1 + N2 <= 1`, the function returns the output array unchanged.
1312

1413
Parameters
1514
----------
1615
N: integer
1716
Number of indexed elements.
1817

19-
x: ArrayLikeObject
18+
x: Array|TypedArray
2019
Input array.
2120

2221
sx: integer
2322
Stride length for `x`.
2423

2524
N1: integer
26-
Number of elements to `prepend`.
25+
Number of indexed elements to prepend.
2726

28-
p: ArrayLikeObject
29-
Array containing values to prepend to the output array.
27+
p: Array|TypedArray
28+
Array containing values to prepend after computing differences.
3029

3130
sp: integer
32-
Stride length for `prepend`.
31+
Stride length for `p`.
3332

3433
N2: integer
35-
Number of elements to `append`.
34+
Number of indexed elements to append.
3635

37-
a: ArrayLikeObject
38-
Array containing values to append to the output array.
36+
a: Array|TypedArray
37+
Array containing values to append after computing differences.
3938

4039
sa: integer
41-
Stride length for `append`.
40+
Stride length for `a`.
4241

43-
out: ArrayLikeObject
44-
Output array.
42+
out: Array|TypedArray
43+
Output array. Must have `N + N1 + N2 - 1` indexed elements.
4544

4645
so: integer
4746
Stride length for `out`.
4847

4948
Returns
5049
-------
51-
out: ArrayLikeObject
50+
out: Array|TypedArray
5251
Output array.
5352

5453
Examples
5554
--------
56-
// Standard Usage:
55+
// Standard usage:
5756
> var x = [ 1.0, -2.0, 2.0 ];
5857
> var p = [ 0.0 ];
5958
> var a = [ 3.0 ];
@@ -65,7 +64,7 @@
6564
> x = [ 2.0, 4.0, 6.0, 8.0, 10.0 ];
6665
> p = [ 1.0 ];
6766
> a = [ 11.0 ];
68-
> var out = [ 0.0, 0.0, 0.0, 0.0 ];
67+
> out = [ 0.0, 0.0, 0.0, 0.0 ];
6968
> {{alias}}( 3, x, 2, 1, p, 1, 1, a, 1, out, 1 )
7069
[ 1.0, 4.0, 4.0, 11.0 ]
7170

@@ -74,12 +73,12 @@
7473
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
7574
> p = [ 1.0 ];
7675
> a = [ 11.0 ];
77-
> var out = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
76+
> out = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
7877
> {{alias}}( x1.length, x1, 1, 1, p, 1, 1, a, 1, out, 1 )
7978
[ 1.0, 2.0, 2.0, 2.0, 11.0 ]
8079

8180

82-
{{alias}}.ndarray( N, x, sx, ox, N1, p, sp, op, N2, a, sa, oa, out, so, oo )
81+
{{alias}}.ndarray( N, x,sx,ox, N1, p,sp,op, N2, a,sa,oa, out,so,oo )
8382
Calculates the differences between consecutive elements of a strided array
8483
using alternative indexing semantics.
8584

@@ -92,7 +91,7 @@
9291
N: integer
9392
Number of indexed elements.
9493

95-
x: ArrayLikeObject
94+
x: Array|TypedArray
9695
Input array.
9796

9897
sx: integer
@@ -102,31 +101,31 @@
102101
Starting index for `x`.
103102

104103
N1: integer
105-
Number of elements to `prepend`.
104+
Number of indexed elements to prepend.
106105

107-
p: ArrayLikeObject
108-
Array containing values to prepend to the output array.
106+
p: Array|TypedArray
107+
Array containing values to prepend after computing differences.
109108

110109
sp: integer
111-
Stride length for `prepend`.
110+
Stride length for `p`.
112111

113112
op: integer
114-
Starting index for `prepend`.
113+
Starting index for `p`.
115114

116115
N2: integer
117-
Number of elements to `append`.
116+
Number of indexed elements to append.
118117

119-
a: ArrayLikeObject
120-
Array containing values to append to the output array.
118+
a: Array|TypedArray
119+
Array containing values to append after computing differences.
121120

122121
sa: integer
123-
Stride length for `append`.
122+
Stride length for `a`.
124123

125124
oa: integer
126-
Starting index for `append`.
125+
Starting index for `a`.
127126

128-
out: ArrayLikeObject
129-
Output array.
127+
out: Array|TypedArray
128+
Output array. Must have `N + N1 + N2 - 1` indexed elements.
130129

131130
so: integer
132131
Stride length for `out`.
@@ -136,26 +135,27 @@
136135

137136
Returns
138137
-------
139-
out: ArrayLikeObject
138+
out: Array|TypedArray
140139
Output array.
141140

142141
Examples
143142
--------
144-
// Standard Usage:
143+
// Standard usage:
145144
> var x = [ 1.0, -2.0, 2.0 ];
146145
> var p = [ 0.0 ];
147146
> var a = [ 3.0 ];
148147
> var out = [ 0.0, 0.0, 0.0, 0.0 ];
149-
> {{alias}}.ndarray( 3, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 )
148+
> {{alias}}.ndarray( 3, x,1,0, 1, p,1,0, 1, a,1,0, out,1,0 )
150149
[ 0.0, -3.0, 4.0, 3.0 ]
151150

152151
// Advanced indexing:
153152
> x = [ 1.0, -2.0, 2.0 ];
154153
> p = [ 0.0 ];
155154
> a = [ 3.0 ];
156155
> out = [ 0.0, 0.0, 0.0 ];
157-
> {{alias}}.ndarray( 2, x, 1, 1, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 )
156+
> {{alias}}.ndarray( 2, x,1,1, 1, p,1,0, 1, a,1,0, out,1,0 )
158157
[ 0.0, 4.0, 3.0 ]
159158

160159
See Also
161160
--------
161+

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

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@
2020

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

23-
import { Collection } from '@stdlib/types/array';
23+
import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';
24+
25+
/**
26+
* Input array.
27+
*/
28+
type InputArray = NumericArray | Collection<number> | AccessorArrayLike<number>;
29+
30+
/**
31+
* Output array.
32+
*/
33+
type OutputArray = NumericArray | Collection<number> | AccessorArrayLike<number>;
2434

2535
/**
2636
* Interface describing `gediff`.
@@ -29,13 +39,17 @@ interface Routine {
2939
/**
3040
* Calculates the differences between consecutive elements of a strided array.
3141
*
42+
* ## Notes
43+
*
44+
* - The `out` array must have `N + N1 + N2 - 1` elements.
45+
*
3246
* @param N - number of indexed elements
3347
* @param x - input array
3448
* @param strideX - stride length for `x`
35-
* @param N1 - number of indexed elements of prepend
49+
* @param N1 - number of indexed elements to `prepend`
3650
* @param prepend - prepend array
3751
* @param strideP - stride length for `prepend`
38-
* @param N2 - number of indexed elements of append
52+
* @param N2 - number of indexed elements to `append`
3953
* @param append - append array
4054
* @param strideA - stride length for `append`
4155
* @param out - output array
@@ -53,20 +67,24 @@ interface Routine {
5367
* console.log( out );
5468
* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ]
5569
*/
56-
<T = unknown, U = unknown, V = unknown, W = unknown>( N: number, x: Collection<T>, strideX: number, N1: number, prepend: Collection<U>, strideP: number, N2: number, append: Collection<V>, strideA: number, out: Collection<W>, strideOut: number ): Collection<W>;
70+
<T extends OutputArray>( N: number, x: InputArray, strideX: number, N1: number, prepend: InputArray, strideP: number, N2: number, append: InputArray, strideA: number, out: T, strideOut: number ): T;
5771

5872
/**
5973
* Calculates the differences between consecutive elements of a strided array using alternative indexing semantics.
6074
*
75+
* ## Notes
76+
*
77+
* - The `out` array must have `N + N1 + N2 - 1` elements.
78+
*
6179
* @param N - number of indexed elements
6280
* @param x - input array
6381
* @param strideX - stride length for `x`
6482
* @param offsetX - starting index for `x`
65-
* @param N1 - number of indexed elements of prepend
83+
* @param N1 - number of indexed elements to `prepend`
6684
* @param prepend - prepend array
6785
* @param strideP - stride length for `prepend`
6886
* @param offsetP - starting index for `prepend`
69-
* @param N2 - number of indexed elements of append
87+
* @param N2 - number of indexed elements to `append`
7088
* @param append - append array
7189
* @param strideA - stride length for `append`
7290
* @param offsetA - starting index for `append`
@@ -86,19 +104,23 @@ interface Routine {
86104
* console.log( out );
87105
* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ]
88106
*/
89-
ndarray<T = unknown, U = unknown, V = unknown, W = unknown>( N: number, x: Collection<T>, strideX: number, offsetX: number, N1: number, prepend: Collection<U>, strideP: number, offsetP: number, N2: number, append: Collection<V>, strideA: number, offsetA: number, out: Collection<W>, strideOut: number, offsetOut: number ): Collection<W>;
107+
ndarray<T extends OutputArray>( N: number, x: InputArray, strideX: number, offsetX: number, N1: number, prepend: InputArray, strideP: number, offsetP: number, N2: number, append: InputArray, strideA: number, offsetA: number, out: T, strideOut: number, offsetOut: number ): T;
90108
}
91109

92110
/**
93111
* Calculates the differences between consecutive elements of a strided array.
94112
*
113+
* ## Notes
114+
*
115+
* - The `out` array must have `N + N1 + N2 - 1` elements.
116+
*
95117
* @param N - number of indexed elements
96118
* @param x - input array
97119
* @param strideX - stride length for `x`
98-
* @param N1 - number of indexed elements of prepend
120+
* @param N1 - number of indexed elements to `prepend`
99121
* @param prepend - prepend array
100122
* @param strideP - stride length for `prepend`
101-
* @param N2 - number of indexed elements of append
123+
* @param N2 - number of indexed elements to `append`
102124
* @param append - append array
103125
* @param strideA - stride length for `append`
104126
* @param out - output array

lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ import gediff = require( './index' );
224224
gediff( x.length, x, 1, 1, p, 1, 1, a ); // $ExpectError
225225
gediff( x.length, x, 1, 1, p, 1, 1, a, 1 ); // $ExpectError
226226
gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out ); // $ExpectError
227-
gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1, 10 ); // $ExpectError
227+
gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1, {} ); // $ExpectError
228228
}
229229

230230
// Attached to main export is an `ndarray` method which returns a collection...
@@ -502,5 +502,5 @@ import gediff = require( './index' );
502502
gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0 ); // $ExpectError
503503
gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out ); // $ExpectError
504504
gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1 ); // $ExpectError
505-
gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, 10 ); // $ExpectError
505+
gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, {} ); // $ExpectError
506506
}

lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ console.log( 'Append array: ', a );
4040
var out = zeros( 13 );
4141

4242
gediff( x.length, x, 1, 2, p, 1, 2, a, 1, out, 1 );
43-
console.log( 'Output', out );
43+
console.log( 'Output: ', out );

lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,24 @@ var gcopy = require( '@stdlib/blas/base/gcopy' );
3636
* @param {Collection} x.data - input array data
3737
* @param {Array<Function>} x.accessors - array element accessors
3838
* @param {integer} strideX - stride length for `x`
39-
* @param {NonNegativeInteger} offsetX - starting index for `x`
40-
* @param {PositiveInteger} N1 - number of indexed elements of prepend
39+
* @param {PositiveInteger} offsetX - starting index for `x`
40+
* @param {PositiveInteger} N1 - number of indexed elements to `prepend`
4141
* @param {Object} prepend - prepend array object
4242
* @param {Collection} prepend.data - prepend array data
4343
* @param {Array<Function>} prepend.accessors - array element accessors
4444
* @param {integer} strideP - stride length for `prepend`
45-
* @param {NonNegativeInteger} offsetP - starting index for `prepend`
46-
* @param {PositiveInteger} N2 - number of indexed elements of append
45+
* @param {PositiveInteger} offsetP - starting index for `prepend`
46+
* @param {PositiveInteger} N2 - number of indexed elements to `append`
4747
* @param {Object} append - append array object
4848
* @param {Collection} append.data - append array data
4949
* @param {Array<Function>} append.accessors - array element accessors
5050
* @param {integer} strideA - stride length for `append`
51-
* @param {NonNegativeInteger} offsetA - starting index for `append`
51+
* @param {PositiveInteger} offsetA - starting index for `append`
5252
* @param {Object} out - output array object
5353
* @param {Collection} out.data - output array data
5454
* @param {Array<Function>} out.accessors - array element accessors
5555
* @param {integer} strideOut - stride length for `out`
56-
* @param {NonNegativeInteger} offsetOut - starting index for `out`
56+
* @param {PositiveInteger} offsetOut - starting index for `out`
5757
* @returns {Object} output array object
5858
*
5959
* @example

lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ var ndarray = require( './ndarray.js' );
3434
* @param {PositiveInteger} N - number of indexed elements
3535
* @param {Collection} x - input array
3636
* @param {integer} strideX - stride length for `x`
37-
* @param {PositiveInteger} N1 - number of indexed elements of prepend
37+
* @param {PositiveInteger} N1 - number of indexed elements to `prepend`
3838
* @param {Collection} prepend - prepend array
3939
* @param {integer} strideP - stride length for `prepend`
40-
* @param {PositiveInteger} N2 - number of indexed elements of append
40+
* @param {PositiveInteger} N2 - number of indexed elements to `append`
4141
* @param {Collection} append - append array
4242
* @param {integer} strideA - stride length for `append`
4343
* @param {Collection} out - output array

0 commit comments

Comments
 (0)