Skip to content

Commit 7fb3fba

Browse files
committed
Apply Suggestions From the Code Review
1 parent da473ba commit 7fb3fba

7 files changed

Lines changed: 30 additions & 6 deletions

File tree

lib/node_modules/@stdlib/blas/base/ndarray/dswap/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ var ybuf = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
5151
var y = new ndarray( 'float64', ybuf, [ 5 ], [ 1 ], 0, 'row-major' );
5252

5353
var z = dswap( [ x, y ] );
54+
// x => <ndarray>[ 6.0, 7.0, 8.0, 9.0, 10.0 ]
5455
// returns <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
5556

5657
var bool = ( y === z );
@@ -96,6 +97,7 @@ var y = new ndarray( opts.dtype, ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
9697
console.log( ndarray2array( y ) );
9798

9899
var out = dswap( [ x, y ] );
100+
console.log( ndarray2array( x ) );
99101
console.log( ndarray2array( out ) );
100102
```
101103

lib/node_modules/@stdlib/blas/base/ndarray/dswap/docs/repl.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
> var y = new {{alias:@stdlib/ndarray/ctor}}( dt, ybuf, sh, st, oo, ord );
2929

3030
> {{alias}}( [ x, y ] );
31+
> x
32+
<ndarray>[ 0.0, 0.0, 0.0 ]
3133
> y
3234
<ndarray>[ 4.0, 2.0, -3.0 ]
3335

lib/node_modules/@stdlib/blas/base/ndarray/dswap/docs/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { float64ndarray } from '@stdlib/types/ndarray';
3939
* var y = new ndarray( 'float64', ybuf, [ 5 ], [ 1 ], 0, 'row-major' );
4040
*
4141
* var z = dswap( [ x, y ] );
42+
* // x => <ndarray>[ 6.0, 7.0, 8.0, 9.0, 10.0 ]
4243
* // returns <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
4344
*
4445
* var bool = ( z === y );

lib/node_modules/@stdlib/blas/base/ndarray/dswap/examples/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ var y = new ndarray( opts.dtype, ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
3636
console.log( ndarray2array( y ) );
3737

3838
var out = dswap( [ x, y ] );
39+
console.log( ndarray2array( x ) );
3940
console.log( ndarray2array( out ) );

lib/node_modules/@stdlib/blas/base/ndarray/dswap/lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* var y = new ndarray( 'float64', ybuf, [ 5 ], [ 1 ], 0, 'row-major' );
3636
*
3737
* var z = dswap( [ x, y ] );
38+
* // x => <ndarray>[ 6.0, 7.0, 8.0, 9.0, 10.0 ]
3839
* // returns <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
3940
*
4041
* var bool = ( z === y );

lib/node_modules/@stdlib/blas/base/ndarray/dswap/lib/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var strided = require( '@stdlib/blas/base/dswap' ).ndarray;
4646
* var y = new ndarray( 'float64', ybuf, [ 5 ], [ 1 ], 0, 'row-major' );
4747
*
4848
* var z = dswap( [ x, y ] );
49+
* // x => <ndarray>[ 6.0, 7.0, 8.0, 9.0, 10.0 ]
4950
* // returns <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
5051
*
5152
* var bool = ( z === y );

lib/node_modules/@stdlib/blas/base/ndarray/dswap/test/test.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ tape( 'the function interchanges two one-dimensional ndarrays', function test( t
7373

7474
v = dswap( [ x, y ] );
7575

76-
expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
76+
expected = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
7777
t.strictEqual( v, y, 'returns expected value' );
78+
t.strictEqual( isSameFloat64Array( getData( x ), expected ), true, 'returns expected value' );
79+
80+
expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
7881
t.strictEqual( isSameFloat64Array( getData( v ), expected ), true, 'returns expected value' );
7982

8083
xbuf = new Float64Array( [ 1.0, 2.0 ] );
@@ -84,14 +87,17 @@ tape( 'the function interchanges two one-dimensional ndarrays', function test( t
8487

8588
v = dswap( [ x, y ] );
8689

87-
expected = new Float64Array( [ 1.0, 2.0 ] );
90+
expected = new Float64Array( [ 3.0, 4.0 ] );
8891
t.strictEqual( v, y, 'returns expected value' );
92+
t.strictEqual( isSameFloat64Array( getData( x ), expected ), true, 'returns expected value' );
93+
94+
expected = new Float64Array( [ 1.0, 2.0 ] );
8995
t.strictEqual( isSameFloat64Array( getData( v ), expected ), true, 'returns expected value' );
9096

9197
t.end();
9298
});
9399

94-
tape( 'if provided empty ndarrays, the function returns the output ndarray unchanged', function test( t ) {
100+
tape( 'if provided empty ndarrays, the function leaves both ndarrays unchanged', function test( t ) {
95101
var expected;
96102
var xbuf;
97103
var ybuf;
@@ -108,6 +114,7 @@ tape( 'if provided empty ndarrays, the function returns the output ndarray uncha
108114

109115
expected = new Float64Array( [] );
110116
t.strictEqual( v, y, 'returns expected value' );
117+
t.strictEqual( isSameFloat64Array( getData( x ), expected ), true, 'returns expected value' );
111118
t.strictEqual( isSameFloat64Array( getData( v ), expected ), true, 'returns expected value' );
112119

113120
t.end();
@@ -141,8 +148,11 @@ tape( 'the function supports one-dimensional ndarrays having non-unit strides',
141148

142149
v = dswap( [ x, y ] );
143150

144-
expected = new Float64Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] );
151+
expected = new Float64Array( [ 6.0, 2.0, 7.0, 4.0, 8.0 ] );
145152
t.strictEqual( v, y, 'returns expected value' );
153+
t.strictEqual( isSameFloat64Array( getData( x ), expected ), true, 'returns expected value' );
154+
155+
expected = new Float64Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] );
146156
t.strictEqual( isSameFloat64Array( getData( v ), expected ), true, 'returns expected value' );
147157
t.end();
148158
});
@@ -175,8 +185,11 @@ tape( 'the function supports one-dimensional ndarrays having negative strides',
175185

176186
v = dswap( [ x, y ] );
177187

178-
expected = new Float64Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] );
188+
expected = new Float64Array( [ 6.0, 2.0, 7.0, 4.0, 8.0 ] );
179189
t.strictEqual( v, y, 'returns expected value' );
190+
t.strictEqual( isSameFloat64Array( getData( x ), expected ), true, 'returns expected value' );
191+
192+
expected = new Float64Array( [ 1.0, 3.0, 5.0, 9.0, 10.0 ] );
180193
t.strictEqual( isSameFloat64Array( getData( v ), expected ), true, 'returns expected value' );
181194
t.end();
182195
});
@@ -215,8 +228,11 @@ tape( 'the function supports one-dimensional ndarrays having non-zero offsets',
215228

216229
v = dswap( [ x, y ] );
217230

218-
expected = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] );
231+
expected = new Float64Array( [ 0.0, 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0 ] );
219232
t.strictEqual( v, y, 'returns expected value' );
233+
t.strictEqual( isSameFloat64Array( getData( x ), expected ), true, 'returns expected value' );
234+
235+
expected = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] );
220236
t.strictEqual( isSameFloat64Array( getData( v ), expected ), true, 'returns expected value' );
221237
t.end();
222238
});

0 commit comments

Comments
 (0)