Skip to content

Commit a19de08

Browse files
committed
docs(test): align cumaxabs examples and tests with ndarray instance notation
--- 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: na - 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 9a28d7c commit a19de08

File tree

7 files changed

+39
-52
lines changed

7 files changed

+39
-52
lines changed

lib/node_modules/@stdlib/stats/base/ndarray/cumaxabs/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ var cumaxabs = require( '@stdlib/stats/base/ndarray/cumaxabs' );
4141
Computes the cumulative maximum absolute value of a one-dimensional ndarray.
4242

4343
```javascript
44-
var ndarray2array = require( '@stdlib/ndarray/to-array' );
4544
var ndarray = require( '@stdlib/ndarray/base/ctor' );
4645

4746
var xbuf = [ 1.0, -3.0, 4.0, -2.0 ];
@@ -51,13 +50,10 @@ var ybuf = [ 0.0, 0.0, 0.0, 0.0 ];
5150
var y = new ndarray( 'generic', ybuf, [ 4 ], [ 1 ], 0, 'row-major' );
5251

5352
var v = cumaxabs( [ x, y ] );
54-
// returns <ndarray>
53+
// returns <ndarray>[ 1.0, 3.0, 4.0, 4.0 ]
5554

5655
var bool = ( v === y );
5756
// returns true
58-
59-
var arr = ndarray2array( v );
60-
// returns [ 1.0, 3.0, 4.0, 4.0 ]
6157
```
6258

6359
The function has the following parameters:

lib/node_modules/@stdlib/stats/base/ndarray/cumaxabs/benchmark/benchmark.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ function createBenchmark( len ) {
5353
var x;
5454
var y;
5555

56-
// Include negative values so abs() actually matters:
5756
xbuf = uniform( len, -10.0, 10.0, options );
5857
x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' );
5958

@@ -75,7 +74,6 @@ function createBenchmark( len ) {
7574
}
7675
b.toc();
7776

78-
// Check the final cumulative value:
7977
if ( isnan( v.get( len-1 ) ) ) {
8078
b.fail( 'should not return NaN' );
8179
}

lib/node_modules/@stdlib/stats/base/ndarray/cumaxabs/docs/types/index.d.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { ndarray, typedndarray } from '@stdlib/types/ndarray';
2929
* @returns output ndarray
3030
*
3131
* @example
32-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
3332
* var ndarray = require( '@stdlib/ndarray/base/ctor' );
3433
*
3534
* var xbuf = [ -1.0, 3.0, -4.0, 2.0 ];
@@ -39,13 +38,10 @@ import { ndarray, typedndarray } from '@stdlib/types/ndarray';
3938
* var y = new ndarray( 'generic', ybuf, [ 4 ], [ 1 ], 0, 'row-major' );
4039
*
4140
* var v = cumaxabs( [ x, y ] );
42-
* // returns <ndarray>
41+
* // returns <ndarray>[ 1.0, 3.0, 4.0, 4.0 ]
4342
*
4443
* var bool = ( v === y );
4544
* // returns true
46-
*
47-
* var arr = ndarray2array( v );
48-
* // returns [ 1.0, 3.0, 4.0, 4.0 ]
4945
*/
5046
declare function cumaxabs<T extends typedndarray<unknown> = typedndarray<unknown>>( arrays: [ ndarray, T ] ): T;
5147

lib/node_modules/@stdlib/stats/base/ndarray/cumaxabs/examples/index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,14 @@ var ndarray2array = require( '@stdlib/ndarray/to-array' );
2525
var cumaxabs = require( './../lib' );
2626

2727
// Create an input ndarray with both positive and negative values:
28-
var xbuf = discreteUniform( 10, -50, 50, {
28+
var xbuf = discreteUniform(10, -50, 50, {
2929
'dtype': 'generic'
3030
});
31-
var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
32-
console.log( 'x:', ndarray2array( x ) );
31+
var x = new ndarray('generic', xbuf, [xbuf.length], [1], 0, 'row-major');
32+
console.log(ndarray2array(x));
3333

34-
// Create an output ndarray:
35-
var y = zerosLike( x );
36-
console.log( 'y (before):', ndarray2array( y ) );
34+
var y = zerosLike(x);
35+
console.log(ndarray2array(y));
3736

38-
// Compute cumulative maximum absolute values:
39-
var v = cumaxabs( [ x, y ] );
40-
console.log( 'cumaxabs(x):', ndarray2array( v ) );
37+
var v = cumaxabs([x, y]);
38+
console.log(ndarray2array(v));

lib/node_modules/@stdlib/stats/base/ndarray/cumaxabs/lib/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* @module @stdlib/stats/base/ndarray/cumaxabs
2525
*
2626
* @example
27-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
2827
* var ndarray = require( '@stdlib/ndarray/base/ctor' );
2928
* var cumaxabs = require( '@stdlib/stats/base/ndarray/cumaxabs' );
3029
*
@@ -35,13 +34,10 @@
3534
* var y = new ndarray( 'generic', ybuf, [ 4 ], [ 1 ], 0, 'row-major' );
3635
*
3736
* var v = cumaxabs( [ x, y ] );
38-
* // returns <ndarray>
37+
* // returns <ndarray>[ 1.0, 3.0, 4.0, 4.0 ]
3938
*
4039
* var bool = ( v === y );
4140
* // returns true
42-
*
43-
* var arr = ndarray2array( v );
44-
* // returns [ 1.0, 3.0, 4.0, 4.0 ]
4541
*/
4642

4743
// MODULES //

lib/node_modules/@stdlib/stats/base/ndarray/cumaxabs/lib/main.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ var strided = require( '@stdlib/stats/base/cumaxabs' ).ndarray;
3636
* @returns {ndarrayLike} output ndarray
3737
*
3838
* @example
39-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
4039
* var ndarray = require( '@stdlib/ndarray/base/ctor' );
4140
*
4241
* var xbuf = [ -1.0, 3.0, -4.0, 2.0 ];
@@ -46,13 +45,10 @@ var strided = require( '@stdlib/stats/base/cumaxabs' ).ndarray;
4645
* var y = new ndarray( 'generic', ybuf, [ 4 ], [ 1 ], 0, 'row-major' );
4746
*
4847
* var v = cumaxabs( [ x, y ] );
49-
* // returns <ndarray>
48+
* // returns <ndarray>[ 1.0, 3.0, 4.0, 4.0 ]
5049
*
5150
* var bool = ( v === y );
5251
* // returns true
53-
*
54-
* var arr = ndarray2array( v );
55-
* // returns [ 1.0, 3.0, 4.0, 4.0 ]
5652
*/
5753
function cumaxabs( arrays ) {
5854
var x = arrays[ 0 ];

lib/node_modules/@stdlib/stats/base/ndarray/cumaxabs/test/test.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var cumaxabs = require( './../lib' );
3434
* Returns a one-dimensional ndarray.
3535
*
3636
* @private
37-
* @param {Array} buffer - underlying data buffer
37+
* @param {Collection} buffer - underlying data buffer
3838
* @param {NonNegativeInteger} length - number of indexed elements
3939
* @param {integer} stride - stride length
4040
* @param {NonNegativeInteger} offset - index offset
@@ -72,8 +72,8 @@ tape( 'the function calculates the cumulative maximum absolute value of a one-di
7272
v = cumaxabs( [ x, y ] );
7373
expected = [ 1.0, 2.0, 4.0, 5.0, 5.0, 5.0 ];
7474

75-
t.strictEqual( v, y, 'returns output array' );
76-
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected values' );
75+
t.strictEqual( v, y, 'returns expected value' );
76+
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected value' );
7777

7878
xbuf = [ -4.0, -5.0 ];
7979
x = vector( xbuf, 2, 1, 0 );
@@ -82,7 +82,7 @@ tape( 'the function calculates the cumulative maximum absolute value of a one-di
8282
v = cumaxabs( [ x, y ] );
8383
expected = [ 4.0, 5.0 ];
8484

85-
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected values' );
85+
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected value' );
8686

8787
xbuf = [ -0.0, 0.0, -0.0 ];
8888
x = vector( xbuf, 3, 1, 0 );
@@ -91,7 +91,7 @@ tape( 'the function calculates the cumulative maximum absolute value of a one-di
9191
v = cumaxabs( [ x, y ] );
9292
expected = [ 0.0, 0.0, 0.0 ];
9393

94-
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected values' );
94+
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected value' );
9595

9696
xbuf = [ NaN ];
9797
x = vector( xbuf, 1, 1, 0 );
@@ -100,7 +100,7 @@ tape( 'the function calculates the cumulative maximum absolute value of a one-di
100100
v = cumaxabs( [ x, y ] );
101101
expected = [ NaN ];
102102

103-
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected values' );
103+
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected value' );
104104

105105
xbuf = [ NaN, NaN ];
106106
x = vector( xbuf, 2, 1, 0 );
@@ -109,7 +109,7 @@ tape( 'the function calculates the cumulative maximum absolute value of a one-di
109109
v = cumaxabs( [ x, y ] );
110110
expected = [ NaN, NaN ];
111111

112-
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected values' );
112+
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected value' );
113113

114114
t.end();
115115
});
@@ -124,8 +124,8 @@ tape( 'if provided an empty ndarray, the function returns the output array uncha
124124

125125
v = cumaxabs( [ x, y ] );
126126

127-
t.strictEqual( v, y, 'returns output array' );
128-
t.strictEqual( getData( v ).length, 0, 'output array is empty' );
127+
t.strictEqual( v, y, 'returns expected value' );
128+
t.strictEqual( getData( v ).length, 0, 'returns expected value' );
129129
t.end();
130130
});
131131

@@ -136,7 +136,6 @@ tape( 'the function supports non-unit strides', function test( t ) {
136136
var x;
137137
var y;
138138
var v;
139-
var i;
140139

141140
xbuf = [
142141
1.0, // 0
@@ -150,10 +149,16 @@ tape( 'the function supports non-unit strides', function test( t ) {
150149
];
151150
x = vector( xbuf, 4, 2, 0 );
152151

153-
ybuf = [];
154-
for ( i = 0; i < 8; i++ ) {
155-
ybuf.push( 0.0 );
156-
}
152+
ybuf = [
153+
0.0,
154+
0.0,
155+
0.0,
156+
0.0,
157+
0.0,
158+
0.0,
159+
0.0,
160+
0.0
161+
];
157162
y = vector( ybuf, 4, 2, 0 );
158163

159164
v = cumaxabs( [ x, y ] );
@@ -169,7 +174,7 @@ tape( 'the function supports non-unit strides', function test( t ) {
169174
0.0
170175
];
171176

172-
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected values' );
177+
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected value' );
173178
t.end();
174179
});
175180

@@ -180,7 +185,6 @@ tape( 'the function supports negative strides and offsets', function test( t ) {
180185
var x;
181186
var y;
182187
var v;
183-
var i;
184188

185189
xbuf = [
186190
1.0, // 2
@@ -191,10 +195,13 @@ tape( 'the function supports negative strides and offsets', function test( t ) {
191195
];
192196
x = vector( xbuf, 3, -2, 4 );
193197

194-
ybuf = [];
195-
for ( i = 0; i < 5; i++ ) {
196-
ybuf.push( 0.0 );
197-
}
198+
ybuf = [
199+
0.0,
200+
0.0,
201+
0.0,
202+
0.0,
203+
0.0
204+
];
198205
y = vector( ybuf, 3, -1, 2 );
199206

200207
v = cumaxabs( [ x, y ] );
@@ -207,6 +214,6 @@ tape( 'the function supports negative strides and offsets', function test( t ) {
207214
0.0
208215
];
209216

210-
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected values' );
217+
t.strictEqual( isSameArray( getData( v ), expected ), true, 'returns expected value' );
211218
t.end();
212219
});

0 commit comments

Comments
 (0)