Skip to content

Commit 25ec2d8

Browse files
add support for accessor arrays
1 parent cd6dc2a commit 25ec2d8

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lib/node_modules/@stdlib/stats/base/cumax/lib/accessors.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
4646
* var x = toAccessorArray( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
4747
* var y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
4848
*
49-
* var v = cumax( 4, arraylike2object( x ), 2, 1, arraylike2object( y ), 1, 0 );
50-
* console.log( x );
51-
* // => [ 1.0, 1.0, 2.0, 4.0, 0.0, 0.0, 0.0, 0.0 ]
49+
* cumax( 4, arraylike2object( x ), 2, 1, arraylike2object( y ), 1, 0 );
50+
* // y => [ 1.0, 1.0, 2.0, 4.0, 0.0, 0.0, 0.0, 0.0 ]
5251
*/
5352
function cumax( N, x, strideX, offsetX, y, strideY, offsetY ) {
5453
var xbuf;

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,20 @@ tape( 'the function returns a reference to the output array', function test( t )
199199
t.end();
200200
});
201201

202+
tape( 'the function returns a reference to the output array (accessors)', function test( t ) {
203+
var out;
204+
var x;
205+
var y;
206+
207+
x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
208+
y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] );
209+
210+
out = cumax( x.length, x, 1, 0, y, 1, 0 );
211+
t.strictEqual( out, y, 'same reference' );
212+
213+
t.end();
214+
});
215+
202216
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) {
203217
var expected;
204218
var x;

0 commit comments

Comments
 (0)