Skip to content

Commit ee5f1ef

Browse files
authored
docs: improve doctests for ndarray instances
PR-URL: #16595 Reviewed-by: Athan Reines <[email protected]> Ref: #9329
1 parent 0c06626 commit ee5f1ef

5 files changed

Lines changed: 9 additions & 39 deletions

File tree

‎lib/node_modules/@stdlib/ndarray/base/to-reversed-dimension/README.md‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,23 @@ Returns a new ndarray where the order of elements of an input ndarray along a sp
4646

4747
```javascript
4848
var ndarray = require( '@stdlib/ndarray/ctor' );
49-
var ndarray2array = require( '@stdlib/ndarray/to-array' );
5049

5150
var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
5251
var shape = [ 3, 2 ];
5352
var strides = [ 2, 1 ];
5453
var offset = 0;
5554

5655
var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
57-
// returns <ndarray>
56+
// returns <ndarray>[ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
5857

5958
var sh = x.shape;
6059
// returns [ 3, 2 ]
6160

62-
var arr = ndarray2array( x );
63-
// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
64-
6561
var y = toReversedDimension( x, 0 );
66-
// returns <ndarray>
62+
// returns <ndarray>[ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
6763

6864
sh = y.shape;
6965
// returns [ 3, 2 ]
70-
71-
arr = ndarray2array( y );
72-
// returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
7366
```
7467

7568
The function accepts the following arguments:

‎lib/node_modules/@stdlib/ndarray/base/to-reversed-dimension/docs/repl.txt‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@
2525
> x.shape
2626
[ 2, 2 ]
2727
> var y = {{alias}}( x, 0 )
28-
<ndarray>
28+
<ndarray>[ [ 3, 4 ], [ 1, 2 ] ]
2929
> y.shape
3030
[ 2, 2 ]
31-
> {{alias:@stdlib/ndarray/to-array}}( y )
32-
[ [ 3, 4 ], [ 1, 2 ] ]
3331

3432
See Also
3533
--------

‎lib/node_modules/@stdlib/ndarray/base/to-reversed-dimension/docs/types/index.d.ts‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,23 @@ import { ndarray } from '@stdlib/types/ndarray';
3232
* @example
3333
* var typedarray = require( '@stdlib/array/typed' );
3434
* var ndarray = require( '@stdlib/ndarray/ctor' );
35-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
3635
*
3736
* var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' );
3837
* var shape = [ 3, 2 ];
3938
* var strides = [ 2, 1 ];
4039
* var offset = 0;
4140
*
4241
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
43-
* // returns <ndarray>
42+
* // returns <ndarray>[ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
4443
*
4544
* var sh = x.shape;
4645
* // returns [ 3, 2 ]
4746
*
48-
* var arr = ndarray2array( x );
49-
* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
50-
*
5147
* var y = toReversedDimension( x, 0 );
52-
* // returns <ndarray>
48+
* // returns <ndarray>[ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
5349
*
5450
* sh = y.shape;
5551
* // returns [ 3, 2 ]
56-
*
57-
* arr = ndarray2array( y );
58-
* // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
5952
*/
6053
declare function toReversedDimension<T extends ndarray = ndarray>( x: T, dim: number ): T;
6154

‎lib/node_modules/@stdlib/ndarray/base/to-reversed-dimension/lib/index.js‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
*
2626
* @example
2727
* var ndarray = require( '@stdlib/ndarray/ctor' );
28-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
2928
* var toReversedDimension = require( '@stdlib/ndarray/base/to-reversed-dimension' );
3029
*
3130
* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
@@ -34,22 +33,16 @@
3433
* var offset = 0;
3534
*
3635
* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
37-
* // returns <ndarray>
36+
* // returns <ndarray>[ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
3837
*
3938
* var sh = x.shape;
4039
* // returns [ 3, 2 ]
4140
*
42-
* var arr = ndarray2array( x );
43-
* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
44-
*
4541
* var y = toReversedDimension( x, 0 );
46-
* // returns <ndarray>
42+
* // returns <ndarray>[ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
4743
*
4844
* sh = y.shape;
4945
* // returns [ 3, 2 ]
50-
*
51-
* arr = ndarray2array( y );
52-
* // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
5346
*/
5447

5548
// MODULES //

‎lib/node_modules/@stdlib/ndarray/base/to-reversed-dimension/lib/main.js‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,23 @@ var assign = require( '@stdlib/ndarray/base/assign' );
3636
*
3737
* @example
3838
* var ndarray = require( '@stdlib/ndarray/ctor' );
39-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
4039
*
4140
* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
4241
* var shape = [ 3, 2 ];
4342
* var strides = [ 2, 1 ];
4443
* var offset = 0;
4544
*
4645
* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
47-
* // returns <ndarray>
46+
* // returns <ndarray>[ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
4847
*
4948
* var sh = x.shape;
5049
* // returns [ 3, 2 ]
5150
*
52-
* var arr = ndarray2array( x );
53-
* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
54-
*
5551
* var y = toReversedDimension( x, 0 );
56-
* // returns <ndarray>
52+
* // returns <ndarray>[ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
5753
*
5854
* sh = y.shape;
5955
* // returns [ 3, 2 ]
60-
*
61-
* arr = ndarray2array( y );
62-
* // returns [ [ 5.0, 6.0 ], [ 3.0, 4.0 ], [ 1.0, 2.0 ] ]
6356
*/
6457
function toReversedDimension( x, dim ) {
6558
var out;

0 commit comments

Comments
 (0)