Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 12 additions & 44 deletions lib/node_modules/@stdlib/stats/range-by/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ function clbk( v ) {
}

var y = rangeBy( x, clbk );
// returns <ndarray>

var v = y.get();
// returns 10.0
// returns <ndarray>[ 10 ]
```

The function has the following parameters:
Expand Down Expand Up @@ -89,10 +86,7 @@ var ctx = {
'count': 0
};
var y = rangeBy( x, clbk, ctx );
// returns <ndarray>

var v = y.get();
// returns 10.0
// returns <ndarray>[ 10 ]

var count = ctx.count;
// returns 3
Expand All @@ -107,7 +101,6 @@ The function accepts the following options:
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.

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

function clbk( v ) {
Expand All @@ -118,41 +111,30 @@ var x = array( [ -1.0, 2.0, -3.0, 4.0 ], {
'shape': [ 2, 2 ],
'order': 'row-major'
});
var v = ndarray2array( x );
// returns [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]
// returns <ndarray>[ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]

var opts = {
'dims': [ 0 ]
};
var y = rangeBy( x, opts, clbk );
// returns <ndarray>

v = ndarray2array( y );
// returns [ 200.0, 200.0 ]
// returns <ndarray>[ [ 200, 200 ] ]

opts = {
'dims': [ 1 ]
};
y = rangeBy( x, opts, clbk );
// returns <ndarray>

v = ndarray2array( y );
// returns [ 300.0, 700.0 ]
// returns <ndarray>[ [ 300, 700 ] ]

opts = {
'dims': [ 0, 1 ]
};
y = rangeBy( x, opts, clbk );
// returns <ndarray>

v = y.get();
// returns 700.0
// returns <ndarray>[ 700 ]
```

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`.

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

function clbk( v ) {
Expand All @@ -163,39 +145,28 @@ var x = array( [ -1.0, 2.0, -3.0, 4.0 ], {
'shape': [ 2, 2 ],
'order': 'row-major'
});

var v = ndarray2array( x );
// returns [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]
// returns <ndarray>[ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]

var opts = {
'dims': [ 0 ],
'keepdims': true
};
var y = rangeBy( x, opts, clbk );
// returns <ndarray>

v = ndarray2array( y );
// returns [ [ 200.0, 200.0 ] ]
// returns <ndarray>[ [ [ 200, 200 ] ] ]

opts = {
'dims': [ 1 ],
'keepdims': true
};
y = rangeBy( x, opts, clbk );
// returns <ndarray>

v = ndarray2array( y );
// returns [ [ 300.0 ], [ 700.0 ] ]
// returns <ndarray>[ [ 300 ], [ 700 ] ]

opts = {
'dims': [ 0, 1 ],
'keepdims': true
};
y = rangeBy( x, opts, clbk );
// returns <ndarray>

v = ndarray2array( y );
// returns [ [ 700.0 ] ]
// returns <ndarray>[ [ [ [ 700 ] ] ] ]
```

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.
Expand Down Expand Up @@ -238,10 +209,7 @@ var x = array( [ -1.0, 2.0, -3.0 ] );
var y = zeros( [] );

var out = rangeBy.assign( x, y, clbk );
// returns <ndarray>

var v = out.get();
// returns 500.0
// returns <ndarray>[ 500 ]

var bool = ( out === y );
// returns true
Expand Down Expand Up @@ -316,7 +284,7 @@ var opts = {
var y = rangeBy( x, opts, accessor );

// Resolve the output array data type:
var dt = getDType( y );
var dt = String( getDType( y ) );
console.log( dt );

// Print the results:
Expand Down
8 changes: 3 additions & 5 deletions lib/node_modules/@stdlib/stats/range-by/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
> var x = {{alias:@stdlib/ndarray/array}}( [ -1.0, 2.0, -3.0, 4.0 ] );
> function clbk( v ) { return v * 2.0; };
> var y = {{alias}}( x, clbk );
> var v = y.get()
14.0
> y
<ndarray>[ 14.0 ]


{{alias}}.assign( x, out[, options], clbk[, thisArg] )
Expand Down Expand Up @@ -102,11 +102,9 @@
> var out = {{alias:@stdlib/ndarray/zeros}}( [] );
> function clbk( v ) { return v * 2.0; };
> var y = {{alias}}.assign( x, out, clbk )
<ndarray>
<ndarray>[ 14.0 ]
> var bool = ( out === y )
true
> var v = out.get()
14.0

See Also
--------
Expand Down
20 changes: 4 additions & 16 deletions lib/node_modules/@stdlib/stats/range-by/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ interface Unary {
* var x = array( [ -1.0, 2.0, -3.0 ] );
*
* var y = rangeBy( x, clbk );
* // returns <ndarray>
*
* var v = y.get();
* // returns 10.0
* // returns <ndarray>[ 10.0 ]
*/
<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`.

Expand All @@ -150,10 +147,7 @@ interface Unary {
* var x = array( [ -1.0, 2.0, -3.0 ] );
*
* var y = rangeBy( x, {}, clbk );
* // returns <ndarray>
*
* var v = y.get();
* // returns 10.0
* // returns <ndarray>[ 10.0 ]
*/
<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`.

Expand All @@ -178,10 +172,7 @@ interface Unary {
* }
*
* var out = rangeBy.assign( x, y, clbk );
* // returns <ndarray>
*
* var v = out.get();
* // returns 10.0
* // returns <ndarray>[ 10.0 ]
*
* var bool = ( out === y );
* // returns true
Expand Down Expand Up @@ -210,10 +201,7 @@ interface Unary {
* }
*
* var out = rangeBy.assign( x, y, {}, clbk );
* // returns <ndarray>
*
* var v = out.get();
* // returns 10.0
* // returns <ndarray>[ 10.0 ]
*
* var bool = ( out === y );
* // returns true
Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/stats/range-by/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@
*
* // Perform reduction:
* var out = rangeBy( x, clbk );
* // returns <ndarray>
*
* var v = out.get();
* // returns 18.0
* // returns <ndarray>[ 18.0 ]
*/

// MODULES //
Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/stats/range-by/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ var table = {
*
* // Perform reduction:
* var out = rangeBy( x, clbk );
* // returns <ndarray>
*
* var v = out.get();
* // returns 18.0
* // returns <ndarray>[ 18.0 ]
*/
var rangeBy = factory( table, [ idtypes ], odtypes, policies );

Expand Down