Skip to content

Commit 654ad41

Browse files
docs: improve doctests for ndarray instances in
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent e14ea8a commit 654ad41

File tree

6 files changed

+18
-71
lines changed

6 files changed

+18
-71
lines changed

lib/node_modules/@stdlib/ndarray/any-by/README.md

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ var x = array( [ [ 1.0, -2.0 ], [ 3.0, -4.0 ] ] );
5252

5353
// Test whether at least one element is positive:
5454
var out = anyBy( x, isPositive );
55-
// returns <ndarray>
56-
57-
var v = out.get();
58-
// returns true
55+
// returns <ndarray>[ true ]
5956
```
6057

6158
The function accepts the following arguments:
@@ -73,7 +70,6 @@ The function accepts the following options:
7370
By default, the function performs a reduction over all elements in a provided [`ndarray`][@stdlib/ndarray/ctor]. To reduce specific dimensions, set the `dims` option.
7471

7572
```javascript
76-
var ndarray2array = require( '@stdlib/ndarray/to-array' );
7773
var array = require( '@stdlib/ndarray/array' );
7874

7975
function isPositive( value ) {
@@ -82,23 +78,20 @@ function isPositive( value ) {
8278

8379
// Create an input ndarray:
8480
var x = array( [ [ 1.0, 2.0 ], [ -3.0, -4.0 ] ] );
81+
// returns <ndarray>
8582

8683
var opts = {
8784
'dims': [ 1 ]
8885
};
8986

9087
// Perform reduction:
9188
var out = anyBy( x, opts, isPositive );
92-
// returns <ndarray>
93-
94-
var v = ndarray2array( out );
95-
// returns [ true, false ]
89+
// returns <ndarray>[ true, false ]
9690
```
9791

9892
By default, the function returns an [`ndarray`][@stdlib/ndarray/ctor] having a shape matching only the non-reduced dimensions of the input [`ndarray`][@stdlib/ndarray/ctor] (i.e., the reduced dimensions are dropped). To include the reduced dimensions as singleton dimensions in the output [`ndarray`][@stdlib/ndarray/ctor], set the `keepdims` option to `true`.
9993

10094
```javascript
101-
var ndarray2array = require( '@stdlib/ndarray/to-array' );
10295
var array = require( '@stdlib/ndarray/array' );
10396

10497
function isPositive( value ) {
@@ -114,10 +107,7 @@ var opts = {
114107

115108
// Perform reduction:
116109
var out = anyBy( x, opts, isPositive );
117-
// returns <ndarray>
118-
119-
var v = ndarray2array( out );
120-
// returns [ [ [ true ] ] ]
110+
// returns <ndarray>[ [ [ true ] ] ]
121111
```
122112

123113
To set the function execution context, provide a `thisArg`.
@@ -141,10 +131,7 @@ var ctx = {
141131

142132
// Perform reduction:
143133
var out = anyBy( x, isPositive, ctx );
144-
// returns <ndarray>
145-
146-
var v = out.get();
147-
// returns true
134+
// returns <ndarray>[ true ]
148135

149136
var count = ctx.count;
150137
// returns 4
@@ -172,10 +159,7 @@ var y = empty( [], {
172159

173160
// Perform reduction:
174161
var out = anyBy.assign( x, y, isPositive );
175-
// returns <ndarray>
176-
177-
var v = out.get();
178-
// returns true
162+
// returns <ndarray>[ true ]
179163

180164
var bool = ( out === y );
181165
// returns true
@@ -222,9 +206,6 @@ var out = anyBy.assign( x, y, opts, predicate );
222206

223207
var bool = ( out === y );
224208
// returns true
225-
226-
var v = ndarray2array( y );
227-
// returns [ true, false ]
228209
```
229210

230211
</section>

lib/node_modules/@stdlib/ndarray/any-by/docs/repl.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
<ndarray>
3939
> function f( v ) { return v > 0.0; };
4040
> var out = {{alias}}( x, f )
41-
<ndarray>
42-
> out.get()
43-
true
41+
<ndarray>[ true ]
4442

4543

4644
{{alias}}.assign( x, y[, options], predicate[, thisArg] )
@@ -84,11 +82,9 @@
8482
<ndarray>
8583
> function f( v ) { return v > 0.0; };
8684
> var out = {{alias}}.assign( x, y, f )
87-
<ndarray>
85+
<ndarray>[ true ]
8886
> var bool = ( y === out )
8987
true
90-
> out.get()
91-
true
9288

9389
See Also
9490
--------

lib/node_modules/@stdlib/ndarray/any-by/docs/types/index.d.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ interface AnyBy {
129129
*
130130
* // Perform reduction:
131131
* var out = anyBy( x, isPositive );
132-
* // returns <ndarray>
133-
*
134-
* var v = out.get();
135-
* // returns true
132+
* // returns <ndarray>[ true ]
136133
*/
137134
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): boolndarray;
138135

@@ -172,10 +169,7 @@ interface AnyBy {
172169
*
173170
* // Perform reduction:
174171
* var out = anyBy( x, {}, isPositive );
175-
* // returns <ndarray>
176-
*
177-
* var v = out.get();
178-
* // returns true
172+
* // returns <ndarray>[ true ]
179173
*/
180174
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, options: Options, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): boolndarray;
181175

@@ -219,10 +213,7 @@ interface AnyBy {
219213
*
220214
* // Perform reduction:
221215
* var out = anyBy.assign( x, y, isPositive );
222-
* // returns <ndarray>
223-
*
224-
* var v = out.get();
225-
* // returns true
216+
* // returns <ndarray>[ true ]
226217
*/
227218
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends ndarray = ndarray, ThisArg = unknown>( x: U, y: V, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;
228219

@@ -268,10 +259,7 @@ interface AnyBy {
268259
*
269260
* // Perform reduction:
270261
* var out = anyBy.assign( x, y, {}, isPositive );
271-
* // returns <ndarray>
272-
*
273-
* var v = out.get();
274-
* // returns true
262+
* // returns <ndarray>[ true ]
275263
*/
276264
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends ndarray = ndarray, ThisArg = unknown>( x: U, y: V, options: BaseOptions, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;
277265
}
@@ -312,10 +300,7 @@ interface AnyBy {
312300
*
313301
* // Perform reduction:
314302
* var out = anyBy( x, isPositive );
315-
* // returns <ndarray>
316-
*
317-
* var v = out.get();
318-
* // returns true
303+
* // returns <ndarray>[ true ]
319304
*
320305
* @example
321306
* var Float64Array = require( '@stdlib/array/float64' );
@@ -348,10 +333,7 @@ interface AnyBy {
348333
*
349334
* // Perform reduction:
350335
* var out = anyBy.assign( x, y, isPositive );
351-
* // returns <ndarray>
352-
*
353-
* var v = out.get();
354-
* // returns true
336+
* // returns <ndarray>[ true ]
355337
*/
356338
declare var anyBy: AnyBy;
357339

lib/node_modules/@stdlib/ndarray/any-by/lib/assign.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,10 @@ var validate = require( './validate.js' );
8181
*
8282
* // Perform reduction:
8383
* var out = assign( x, y, isPositive );
84-
* // returns <ndarray>
84+
* // returns <ndarray>[ true]
8585
*
8686
* var bool = ( out === y );
8787
* // returns true
88-
*
89-
* var v = out.get();
90-
* // returns true
9188
*/
9289
function assign( x, y, options, predicate, thisArg ) {
9390
var nargs;

lib/node_modules/@stdlib/ndarray/any-by/lib/index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@
4949
*
5050
* // Perform reduction:
5151
* var out = anyBy( x, isPositive );
52-
* // returns <ndarray>
53-
*
54-
* var v = out.get();
55-
* // returns true
52+
* // returns <ndarray>[ true ]
5653
*
5754
* @example
5855
* var Float64Array = require( '@stdlib/array/float64' );
@@ -86,10 +83,7 @@
8683
*
8784
* // Perform reduction:
8885
* var out = anyBy.assign( x, y, isPositive );
89-
* // returns <ndarray>
90-
*
91-
* var v = out.get();
92-
* // returns true
86+
* // returns <ndarray>[ true ]
9387
*/
9488

9589
// MODULES //

lib/node_modules/@stdlib/ndarray/any-by/lib/main.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ var validate = require( './validate.js' );
8686
*
8787
* // Perform reduction:
8888
* var out = anyBy( x, isPositive );
89-
* // returns <ndarray>
90-
*
91-
* var v = out.get();
92-
* // returns true
89+
* // returns <ndarray>[ true ]
9390
*/
9491
function anyBy( x, options, predicate, thisArg ) {
9592
var nargs;

0 commit comments

Comments
 (0)