Skip to content

Commit 06730fe

Browse files
headlessNodeShabiShett07
authored andcommitted
fix: update return value and tests for blas/ext/base/gcusumkbn
PR-URL: stdlib-js#5064 Reviewed-by: Athan Reines <[email protected]>
1 parent e558571 commit 06730fe

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import gcusumkbn = require( './index' );
2828
const y = new Float64Array( 10 );
2929

3030
gcusumkbn( x.length, 0.0, x, 1, y, 1 ); // $ExpectType Float64Array
31-
gcusumkbn( x.length, 0.0, new AccessorArray( x ), 1, new AccessorArray( y ), 1 ); // $ExpectType AccessorArray
31+
gcusumkbn( x.length, 0.0, new AccessorArray( x ), 1, new AccessorArray( y ), 1 ); // $ExpectType AccessorArray<number>
3232
}
3333

3434
// The compiler throws an error if the function is provided a first argument which is not a number...
@@ -142,7 +142,7 @@ import gcusumkbn = require( './index' );
142142
const y = new Float64Array( 10 );
143143

144144
gcusumkbn.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectType Float64Array
145-
gcusumkbn.ndarray( x.length, 0.0, new AccessorArray( x ), 1, 0, new AccessorArray( y ), 1, 0 ); // $ExpectType AccessorArray
145+
gcusumkbn.ndarray( x.length, 0.0, new AccessorArray( x ), 1, 0, new AccessorArray( y ), 1, 0 ); // $ExpectType AccessorArray<number>
146146
}
147147

148148
// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ var abs = require( '@stdlib/math/base/special/abs' );
5555
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
5656
* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
5757
*
58-
* var x = toAccessorArray( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
59-
* var y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
58+
* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
59+
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
6060
*
61-
* gcusumkbn( 4, 0.0, arraylike2object( x ), 2, 1, arraylike2object( y ), 1, 0 );
61+
* gcusumkbn( 4, 0.0, arraylike2object( toAccessorArray( x ) ), 2, 1, arraylike2object( toAccessorArray( y ) ), 1, 0 );
62+
* // y => [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ]
6263
*/
6364
function gcusumkbn( N, sum, x, strideX, offsetX, y, strideY, offsetY ) {
6465
var xbuf;

lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/lib/ndarray.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ function gcusumkbn( N, sum, x, strideX, offsetX, y, strideY, offsetY ) {
7272
ox = arraylike2object( x );
7373
oy = arraylike2object( y );
7474
if ( ox.accessorProtocol || oy.accessorProtocol ) {
75-
return accessors( N, sum, ox, strideX, offsetX, oy, strideY, offsetY );
75+
accessors( N, sum, ox, strideX, offsetX, oy, strideY, offsetY );
76+
return y;
7677
}
7778
ix = offsetX;
7879
iy = offsetY;

lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.main.js

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

233+
tape( 'the function returns a reference to the output array (accessors)', function test( t ) {
234+
var out;
235+
var x;
236+
var y;
237+
238+
x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
239+
y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] );
240+
241+
out = gcusumkbn( x.length, 0.0, x, 1, y, 1 );
242+
243+
t.strictEqual( out, y, 'same reference' );
244+
t.end();
245+
});
246+
233247
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) {
234248
var expected;
235249
var x;

lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.ndarray.js

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

230+
tape( 'the function returns a reference to the output array (accessors)', function test( t ) {
231+
var out;
232+
var x;
233+
var y;
234+
235+
x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
236+
y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] );
237+
238+
out = gcusumkbn( x.length, 0.0, x, 1, 0, y, 1, 0 );
239+
240+
t.strictEqual( out, y, 'same reference' );
241+
t.end();
242+
});
243+
230244
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) {
231245
var expected;
232246
var x;

0 commit comments

Comments
 (0)