Skip to content
Merged
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
32 changes: 6 additions & 26 deletions lib/node_modules/@stdlib/ndarray/some-by/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] );

// Perform reduction:
var out = someBy( x, 2, predicate );
// returns <ndarray>

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

The function accepts the following arguments:
Expand All @@ -76,7 +73,6 @@ By default, the function performs a reduction over all elements in a provided [`

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

function predicate( value ) {
return value > 0.0;
Expand All @@ -92,17 +88,13 @@ var opts = {

// Perform reduction:
var out = someBy( x, 2, opts, predicate );
// returns <ndarray>

var v = ndarray2array( out );
// returns [ true, true ]
// returns <ndarray>[ true, true ]
```

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

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

function predicate( value ) {
return value > 0.0;
Expand All @@ -119,10 +111,7 @@ var opts = {

// Perform reduction:
var out = someBy( x, 2, opts, predicate );
// returns <ndarray>

var v = ndarray2array( out );
// returns [ [ [ true, true ] ] ]
// returns <ndarray>[ [ [ true, true ] ] ]
```

To set the predicate function execution context, provide a `thisArg`.
Expand All @@ -148,10 +137,7 @@ var ctx = {

// Perform reduction:
var out = someBy( x, 2, predicate, ctx );
// returns <ndarray>

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

var count = ctx.count;
// returns 2
Expand Down Expand Up @@ -180,13 +166,10 @@ var y = empty( [], {

// Perform reduction:
var out = someBy.assign( x, 2, y, predicate );
// returns <ndarray>
// returns <ndarray>[ true ]

var bool = ( out === y );
// returns true

var v = y.get();
// returns true
```

The function accepts the following arguments:
Expand All @@ -207,7 +190,6 @@ By default, the function performs a reduction over all elements in a provided [`
```javascript
var array = require( '@stdlib/ndarray/array' );
var empty = require( '@stdlib/ndarray/empty' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );

function predicate( value ) {
return value > 0.0;
Expand All @@ -228,12 +210,10 @@ var opts = {

// Perform reduction:
var out = someBy.assign( x, 2, y, opts, predicate );
// returns <ndarray>[ true, true ]

var bool = ( out === y );
// returns true

var v = ndarray2array( y );
// returns [ true, true ]
```

</section>
Expand Down
14 changes: 3 additions & 11 deletions lib/node_modules/@stdlib/ndarray/some-by/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,9 @@
> function f ( v ) { return v > 0.0; };
> var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2], [ 3, 4 ] ] );
> var y = {{alias}}( x, 3, f )
<ndarray>
> y.get()
true
<ndarray>[ true ]
> y = {{alias}}( x, 3, { 'keepdims': true }, f )
<ndarray>
> {{alias:@stdlib/ndarray/to-array}}( y )
[ [ true ] ]
> y.get( 0, 0 )
true
<ndarray>[ [ true ] ]


{{alias}}.assign( x, n, y[, options], predicate[, thisArg] )
Expand Down Expand Up @@ -97,11 +91,9 @@
> var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2], [ 3, 4 ] ] );
> var y = {{alias:@stdlib/ndarray/from-scalar}}( false );
> var out = {{alias}}.assign( x, 3, y, f )
<ndarray>
<ndarray>[ true ]
> var bool = ( out === y )
true
> y.get()
true

See Also
--------
Expand Down
30 changes: 6 additions & 24 deletions lib/node_modules/@stdlib/ndarray/some-by/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ interface SomeBy {
*
* // Perform reduction:
* var out = someBy( x, 3, isEven );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*/
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, n: integerndarray | number, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): boolndarray;

Expand Down Expand Up @@ -168,10 +165,7 @@ interface SomeBy {
*
* // Perform reduction:
* var out = someBy( x, 3, {}, isEven );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*/
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, n: integerndarray | number, options: Options, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): boolndarray;

Expand Down Expand Up @@ -213,10 +207,7 @@ interface SomeBy {
*
* // Perform reduction:
* var out = someBy.assign( x, 3, y, isEven );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*/
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends ndarray = ndarray, ThisArg = unknown>( x: ndarray, n: integerndarray | number, y: V, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;

Expand Down Expand Up @@ -260,10 +251,7 @@ interface SomeBy {
*
* // Perform reduction:
* var out = someBy.assign( x, 3, y, {}, isEven );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*/
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends ndarray = ndarray, ThisArg = unknown>( x: ndarray, n: integerndarray | number, y: V, options: BaseOptions, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;
}
Expand Down Expand Up @@ -302,10 +290,7 @@ interface SomeBy {
*
* // Perform reduction:
* var out = someBy( x, 3, isEven );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
Expand Down Expand Up @@ -335,10 +320,7 @@ interface SomeBy {
*
* // Perform reduction:
* var out = someBy.assign( x, 3, y, isEven );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*/
declare var someBy: SomeBy;

Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/ndarray/some-by/lib/assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ var DEFAULT_DTYPE = defaults.get( 'dtypes.integer_index' );
*
* // Perform reduction:
* var out = assign( x, 3, y, isEven );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*/
function assign( x, n, y, options, predicate, thisArg ) {
var nargs;
Expand Down
22 changes: 12 additions & 10 deletions lib/node_modules/@stdlib/ndarray/some-by/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@
* // Create an input ndarray:
* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
*
* // Perform reduction:
* var out = someBy( x, 6 );
* // returns <ndarray>
* function predicate( v ) {
* return v > 0.0;
* }
*
* var v = out.get();
* // returns true
* // Perform reduction:
* var out = someBy( x, 6, predicate );
* // returns <ndarray>[ true ]
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
Expand Down Expand Up @@ -76,12 +77,13 @@
* 'dtype': 'bool'
* });
*
* // Perform reduction:
* var out = someBy.assign( x, 6.0, y );
* // returns <ndarray>
* function predicate( v ) {
* return v > 0.0;
* }
*
* var v = out.get();
* // returns true
* // Perform reduction:
* var out = someBy.assign( x, 6.0, y, predicate );
* // returns <ndarray>[ true ]
*/

// MODULES //
Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/ndarray/some-by/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ var DEFAULT_DTYPE = defaults.get( 'dtypes.integer_index' );
*
* // Perform reduction:
* var out = someBy( x, 3, isEven );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*/
function someBy( x, n, options, predicate, thisArg ) {
var nargs;
Expand Down