Skip to content

Commit 1a8cc79

Browse files
Orthodox-64kgryte
andauthored
docs: update return annotations to use ndarray instance notation in stats/range-by
PR-URL: #8939 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]>
1 parent 2f5534c commit 1a8cc79

File tree

5 files changed

+23
-81
lines changed

5 files changed

+23
-81
lines changed

lib/node_modules/@stdlib/stats/range-by/README.md

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ function clbk( v ) {
5252
}
5353

5454
var y = rangeBy( x, clbk );
55-
// returns <ndarray>
56-
57-
var v = y.get();
58-
// returns 10.0
55+
// returns <ndarray>[ 10.0 ]
5956
```
6057

6158
The function has the following parameters:
@@ -89,10 +86,7 @@ var ctx = {
8986
'count': 0
9087
};
9188
var y = rangeBy( x, clbk, ctx );
92-
// returns <ndarray>
93-
94-
var v = y.get();
95-
// returns 10.0
89+
// returns <ndarray>[ 10.0 ]
9690

9791
var count = ctx.count;
9892
// returns 3
@@ -107,7 +101,6 @@ The function accepts the following options:
107101
By default, the function performs a reduction over all elements in a provided input [ndarray][@stdlib/ndarray/ctor]. To perform a reduction over specific dimensions, provide a `dims` option.
108102

109103
```javascript
110-
var ndarray2array = require( '@stdlib/ndarray/to-array' );
111104
var array = require( '@stdlib/ndarray/array' );
112105

113106
function clbk( v ) {
@@ -118,41 +111,30 @@ var x = array( [ -1.0, 2.0, -3.0, 4.0 ], {
118111
'shape': [ 2, 2 ],
119112
'order': 'row-major'
120113
});
121-
var v = ndarray2array( x );
122-
// returns [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]
114+
// returns <ndarray>[ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]
123115

124116
var opts = {
125117
'dims': [ 0 ]
126118
};
127119
var y = rangeBy( x, opts, clbk );
128-
// returns <ndarray>
129-
130-
v = ndarray2array( y );
131-
// returns [ 200.0, 200.0 ]
120+
// returns <ndarray>[ 200.0, 200.0 ]
132121

133122
opts = {
134123
'dims': [ 1 ]
135124
};
136125
y = rangeBy( x, opts, clbk );
137-
// returns <ndarray>
138-
139-
v = ndarray2array( y );
140-
// returns [ 300.0, 700.0 ]
126+
// returns <ndarray>[ 300.0, 700.0 ]
141127

142128
opts = {
143129
'dims': [ 0, 1 ]
144130
};
145131
y = rangeBy( x, opts, clbk );
146-
// returns <ndarray>
147-
148-
v = y.get();
149-
// returns 700.0
132+
// returns <ndarray>[ 700.0 ]
150133
```
151134

152135
By default, the function excludes reduced dimensions from the output [ndarray][@stdlib/ndarray/ctor]. To include the reduced dimensions as singleton dimensions, set the `keepdims` option to `true`.
153136

154137
```javascript
155-
var ndarray2array = require( '@stdlib/ndarray/to-array' );
156138
var array = require( '@stdlib/ndarray/array' );
157139

158140
function clbk( v ) {
@@ -163,39 +145,28 @@ var x = array( [ -1.0, 2.0, -3.0, 4.0 ], {
163145
'shape': [ 2, 2 ],
164146
'order': 'row-major'
165147
});
166-
167-
var v = ndarray2array( x );
168-
// returns [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]
148+
// returns <ndarray>[ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]
169149

170150
var opts = {
171151
'dims': [ 0 ],
172152
'keepdims': true
173153
};
174154
var y = rangeBy( x, opts, clbk );
175-
// returns <ndarray>
176-
177-
v = ndarray2array( y );
178-
// returns [ [ 200.0, 200.0 ] ]
155+
// returns <ndarray>[ [ 200.0, 200.0 ] ]
179156

180157
opts = {
181158
'dims': [ 1 ],
182159
'keepdims': true
183160
};
184161
y = rangeBy( x, opts, clbk );
185-
// returns <ndarray>
186-
187-
v = ndarray2array( y );
188-
// returns [ [ 300.0 ], [ 700.0 ] ]
162+
// returns <ndarray>[ [ 300.0 ], [ 700.0 ] ]
189163

190164
opts = {
191165
'dims': [ 0, 1 ],
192166
'keepdims': true
193167
};
194168
y = rangeBy( x, opts, clbk );
195-
// returns <ndarray>
196-
197-
v = ndarray2array( y );
198-
// returns [ [ 700.0 ] ]
169+
// returns <ndarray>[ [ 700.0 ] ]
199170
```
200171

201172
By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having a [data type][@stdlib/ndarray/dtypes] determined by the function's output data type [policy][@stdlib/ndarray/output-dtype-policies]. To override the default behavior, set the `dtype` option.
@@ -238,10 +209,7 @@ var x = array( [ -1.0, 2.0, -3.0 ] );
238209
var y = zeros( [] );
239210

240211
var out = rangeBy.assign( x, y, clbk );
241-
// returns <ndarray>
242-
243-
var v = out.get();
244-
// returns 500.0
212+
// returns <ndarray>[ 500.0 ]
245213

246214
var bool = ( out === y );
247215
// returns true
@@ -316,7 +284,7 @@ var opts = {
316284
var y = rangeBy( x, opts, accessor );
317285

318286
// Resolve the output array data type:
319-
var dt = getDType( y );
287+
var dt = String( getDType( y ) );
320288
console.log( dt );
321289

322290
// Print the results:

lib/node_modules/@stdlib/stats/range-by/docs/repl.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
> var x = {{alias:@stdlib/ndarray/array}}( [ -1.0, 2.0, -3.0, 4.0 ] );
5151
> function clbk( v ) { return v * 2.0; };
5252
> var y = {{alias}}( x, clbk );
53-
> var v = y.get()
54-
14.0
53+
> y
54+
<ndarray>[ 14.0 ]
5555

5656

5757
{{alias}}.assign( x, out[, options], clbk[, thisArg] )
@@ -102,11 +102,9 @@
102102
> var out = {{alias:@stdlib/ndarray/zeros}}( [] );
103103
> function clbk( v ) { return v * 2.0; };
104104
> var y = {{alias}}.assign( x, out, clbk )
105-
<ndarray>
105+
<ndarray>[ 14.0 ]
106106
> var bool = ( out === y )
107107
true
108-
> var v = out.get()
109-
14.0
110108

111109
See Also
112110
--------

lib/node_modules/@stdlib/stats/range-by/docs/types/index.d.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ interface Unary {
124124
* var x = array( [ -1.0, 2.0, -3.0 ] );
125125
*
126126
* var y = rangeBy( x, clbk );
127-
* // returns <ndarray>
128-
*
129-
* var v = y.get();
130-
* // returns 10.0
127+
* // returns <ndarray>[ 10.0 ]
131128
*/
132129
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, clbk: Callback<T, U, ThisArg>, thisArg?: ThisParameterType<Callback<T, U, ThisArg>> ): OutputArray<number>; // NOTE: we lose type specificity here, but retaining specificity would likely be difficult and/or tedious to completely enumerate, as the output ndarray data type is dependent on how `x` interacts with output data type policy and whether that policy has been overridden by `options.dtype`.
133130

@@ -150,10 +147,7 @@ interface Unary {
150147
* var x = array( [ -1.0, 2.0, -3.0 ] );
151148
*
152149
* var y = rangeBy( x, {}, clbk );
153-
* // returns <ndarray>
154-
*
155-
* var v = y.get();
156-
* // returns 10.0
150+
* // returns <ndarray>[ 10.0 ]
157151
*/
158152
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, options: Options, clbk: Callback<T, U, ThisArg>, thisArg?: ThisParameterType<Callback<T, U, ThisArg>> ): OutputArray<number>; // NOTE: we lose type specificity here, but retaining specificity would likely be difficult and/or tedious to completely enumerate, as the output ndarray data type is dependent on how `x` interacts with output data type policy and whether that policy has been overridden by `options.dtype`.
159153

@@ -178,10 +172,7 @@ interface Unary {
178172
* }
179173
*
180174
* var out = rangeBy.assign( x, y, clbk );
181-
* // returns <ndarray>
182-
*
183-
* var v = out.get();
184-
* // returns 10.0
175+
* // returns <ndarray>[ 10.0 ]
185176
*
186177
* var bool = ( out === y );
187178
* // returns true
@@ -210,10 +201,7 @@ interface Unary {
210201
* }
211202
*
212203
* var out = rangeBy.assign( x, y, {}, clbk );
213-
* // returns <ndarray>
214-
*
215-
* var v = out.get();
216-
* // returns 10.0
204+
* // returns <ndarray>[ 10.0 ]
217205
*
218206
* var bool = ( out === y );
219207
* // returns true
@@ -240,10 +228,7 @@ interface Unary {
240228
* }
241229
*
242230
* var y = rangeBy( x, clbk );
243-
* // returns <ndarray>
244-
*
245-
* var v = y.get();
246-
* // returns 10.0
231+
* // returns <ndarray>[ 10.0 ]
247232
*
248233
* @example
249234
* var array = require( '@stdlib/ndarray/array' );
@@ -257,10 +242,7 @@ interface Unary {
257242
* }
258243
*
259244
* var out = rangeBy.assign( x, y, clbk );
260-
* // returns <ndarray>
261-
*
262-
* var v = out.get();
263-
* // returns 10.0
245+
* // returns <ndarray>[ 10.0 ]
264246
*
265247
* var bool = ( out === y );
266248
* // returns true

lib/node_modules/@stdlib/stats/range-by/lib/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@
5050
*
5151
* // Perform reduction:
5252
* var out = rangeBy( x, clbk );
53-
* // returns <ndarray>
54-
*
55-
* var v = out.get();
56-
* // returns 18.0
53+
* // returns <ndarray>[ 18.0 ]
5754
*/
5855

5956
// MODULES //

lib/node_modules/@stdlib/stats/range-by/lib/main.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ var table = {
8686
*
8787
* // Perform reduction:
8888
* var out = rangeBy( x, clbk );
89-
* // returns <ndarray>
90-
*
91-
* var v = out.get();
92-
* // returns 18.0
89+
* // returns <ndarray>[ 18.0 ]
9390
*/
9491
var rangeBy = factory( table, [ idtypes ], odtypes, policies );
9592

0 commit comments

Comments
 (0)