Skip to content

Commit a5a3d29

Browse files
docs: improve doctests for ndarray instances in ndarray/filter
PR-URL: #9606 Ref: #9329 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]>
1 parent 1012150 commit a5a3d29

File tree

5 files changed

+40
-195
lines changed

5 files changed

+40
-195
lines changed

lib/node_modules/@stdlib/ndarray/filter/README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ Returns a shallow copy of an [ndarray][@stdlib/ndarray/ctor] containing only tho
4545
```javascript
4646
var Float64Array = require( '@stdlib/array/float64' );
4747
var ndarray = require( '@stdlib/ndarray/ctor' );
48-
var ndarray2array = require( '@stdlib/ndarray/to-array' );
4948

5049
function predicate( z ) {
5150
return z > 6.0;
@@ -60,10 +59,7 @@ var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
6059
// returns <ndarray>
6160

6261
var y = filter( x, predicate );
63-
// returns <ndarray>
64-
65-
var arr = ndarray2array( y );
66-
// returns [ 8.0, 9.0, 10.0 ]
62+
// returns <ndarray>[ 8.0, 9.0, 10.0 ]
6763
```
6864

6965
The function accepts the following arguments:
@@ -86,7 +82,6 @@ By default, the output ndarray [data type][@stdlib/ndarray/dtypes] is inferred f
8682
var Float64Array = require( '@stdlib/array/float64' );
8783
var ndarray = require( '@stdlib/ndarray/ctor' );
8884
var dtype = require( '@stdlib/ndarray/dtype' );
89-
var ndarray2array = require( '@stdlib/ndarray/to-array' );
9085

9186
function predicate( z ) {
9287
return z > 6.0;
@@ -104,13 +99,10 @@ var opts = {
10499
'dtype': 'float32'
105100
};
106101
var y = filter( x, opts, predicate );
107-
// returns <ndarray>
102+
// returns <ndarray>[ 8.0, 9.0, 10.0 ]
108103

109104
var dt = dtype( y );
110105
// returns 'float32'
111-
112-
var arr = ndarray2array( y );
113-
// returns [ 8.0, 9.0, 10.0 ]
114106
```
115107

116108
To set the `predicate` function execution context, provide a `thisArg`.
@@ -120,7 +112,6 @@ To set the `predicate` function execution context, provide a `thisArg`.
120112
```javascript
121113
var Float64Array = require( '@stdlib/array/float64' );
122114
var ndarray = require( '@stdlib/ndarray/ctor' );
123-
var ndarray2array = require( '@stdlib/ndarray/to-array' );
124115

125116
function predicate( z ) {
126117
this.count += 1;
@@ -139,10 +130,7 @@ var ctx = {
139130
'count': 0
140131
};
141132
var y = filter( x, predicate, ctx );
142-
// returns <ndarray>
143-
144-
var arr = ndarray2array( y );
145-
// returns [ 8.0, 9.0, 10.0 ]
133+
// returns <ndarray>[ 8.0, 9.0, 10.0 ]
146134

147135
var count = ctx.count;
148136
// returns 6

lib/node_modules/@stdlib/ndarray/filter/docs/repl.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@
4343
--------
4444
> var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] );
4545
> function f( v ) { return v > 2.0; };
46-
> var y = {{alias}}( x, f );
47-
> {{alias:@stdlib/ndarray/to-array}}( y )
48-
[ 3.0, 4.0 ]
46+
> var y = {{alias}}( x, f )
47+
<ndarray>[ 3.0, 4.0 ]
4948

5049
See Also
5150
--------

0 commit comments

Comments
 (0)