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
33 changes: 7 additions & 26 deletions lib/node_modules/@stdlib/ndarray/any-by/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ var x = array( [ [ 1.0, -2.0 ], [ 3.0, -4.0 ] ] );

// Test whether at least one element is positive:
var out = anyBy( x, isPositive );
// returns <ndarray>

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

The function accepts the following arguments:
Expand All @@ -73,7 +70,6 @@ The function accepts the following options:
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.

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

function isPositive( value ) {
Expand All @@ -82,23 +78,20 @@ function isPositive( value ) {

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

var opts = {
'dims': [ 1 ]
};

// Perform reduction:
var out = anyBy( x, opts, isPositive );
// returns <ndarray>

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

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 ndarray2array = require( '@stdlib/ndarray/to-array' );
var array = require( '@stdlib/ndarray/array' );

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

// Perform reduction:
var out = anyBy( x, opts, isPositive );
// returns <ndarray>

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

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

// Perform reduction:
var out = anyBy( x, isPositive, ctx );
// returns <ndarray>

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

var count = ctx.count;
// returns 4
Expand Down Expand Up @@ -172,10 +159,7 @@ var y = empty( [], {

// Perform reduction:
var out = anyBy.assign( x, y, isPositive );
// returns <ndarray>

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

var bool = ( out === y );
// returns true
Expand All @@ -198,7 +182,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 @@ -219,12 +202,10 @@ var opts = {

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

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

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

</section>
Expand Down
8 changes: 2 additions & 6 deletions lib/node_modules/@stdlib/ndarray/any-by/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
<ndarray>
> function f( v ) { return v > 0.0; };
> var out = {{alias}}( x, f )
<ndarray>
> out.get()
true
<ndarray>[ true ]


{{alias}}.assign( x, y[, options], predicate[, thisArg] )
Expand Down Expand Up @@ -84,11 +82,9 @@
<ndarray>
> function f( v ) { return v > 0.0; };
> var out = {{alias}}.assign( x, y, f )
<ndarray>
<ndarray>[ true ]
> var bool = ( y === out )
true
> out.get()
true

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

Expand Down Expand Up @@ -172,10 +169,7 @@ interface AnyBy {
*
* // Perform reduction:
* var out = anyBy( x, {}, isPositive );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*/
<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;

Expand Down Expand Up @@ -219,10 +213,7 @@ interface AnyBy {
*
* // Perform reduction:
* var out = anyBy.assign( x, y, isPositive );
* // 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: U, y: V, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;

Expand Down Expand Up @@ -268,10 +259,7 @@ interface AnyBy {
*
* // Perform reduction:
* var out = anyBy.assign( x, y, {}, isPositive );
* // 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: U, y: V, options: BaseOptions, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;
}
Expand Down Expand Up @@ -312,10 +300,7 @@ interface AnyBy {
*
* // Perform reduction:
* var out = anyBy( x, isPositive );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
Expand Down Expand Up @@ -348,10 +333,7 @@ interface AnyBy {
*
* // Perform reduction:
* var out = anyBy.assign( x, y, isPositive );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*/
declare var anyBy: AnyBy;

Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/ndarray/any-by/lib/assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,10 @@ var validate = require( './validate.js' );
*
* // Perform reduction:
* var out = assign( x, y, isPositive );
* // returns <ndarray>
* // returns <ndarray>[ true]
*
* var bool = ( out === y );
* // returns true
*
* var v = out.get();
* // returns true
*/
function assign( x, y, options, predicate, thisArg ) {
var nargs;
Expand Down
10 changes: 2 additions & 8 deletions lib/node_modules/@stdlib/ndarray/any-by/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@
*
* // Perform reduction:
* var out = anyBy( x, isPositive );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
Expand Down Expand Up @@ -86,10 +83,7 @@
*
* // Perform reduction:
* var out = anyBy.assign( x, y, isPositive );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*/

// MODULES //
Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/ndarray/any-by/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ var validate = require( './validate.js' );
*
* // Perform reduction:
* var out = anyBy( x, isPositive );
* // returns <ndarray>
*
* var v = out.get();
* // returns true
* // returns <ndarray>[ true ]
*/
function anyBy( x, options, predicate, thisArg ) {
var nargs;
Expand Down