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
27 changes: 5 additions & 22 deletions lib/node_modules/@stdlib/ndarray/count-truthy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] );

// Perform reduction:
var out = countTruthy( x );
// returns <ndarray>

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

The function accepts the following arguments:
Expand All @@ -69,7 +66,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' );

// Create an input ndarray:
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] );
Expand All @@ -79,17 +75,13 @@ var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] );
var out = countTruthy( x, {
'dims': [ 1, 2 ]
});
// returns <ndarray>

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

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' );

// Create an input ndarray:
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] );
Expand All @@ -100,10 +92,7 @@ var out = countTruthy( x, {
'dims': [ 1, 2 ],
'keepdims': true
});
// returns <ndarray>

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

#### countTruthy.assign( x, out\[, options] )
Expand All @@ -125,13 +114,10 @@ var y = empty( [], {

// Perform reduction:
var out = countTruthy.assign( x, y );
// returns <ndarray>
// returns <ndarray>[ 5 ]

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

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

The function accepts the following arguments:
Expand All @@ -149,7 +135,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' );

// Create an input ndarray:
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] );
Expand All @@ -164,12 +149,10 @@ var y = empty( [ 3 ], {
var out = countTruthy.assign( x, y, {
'dims': [ 1, 2 ]
});
// returns <ndarray>[ 2, 2, 1 ]

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

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

</section>
Expand Down
10 changes: 2 additions & 8 deletions lib/node_modules/@stdlib/ndarray/count-truthy/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@
> y.get()
3
> y = {{alias}}( x, { 'keepdims': true } )
<ndarray>
> {{alias:@stdlib/ndarray/to-array}}( y )
[ [ 3 ] ]
> y.get( 0, 0 )
3
<ndarray>[ [ 3 ] ]


{{alias}}.assign( x, y[, options] )
Expand Down Expand Up @@ -71,11 +67,9 @@
> var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 1.0 ], [ 0.0, 1.0 ] ] );
> var y = {{alias:@stdlib/ndarray/from-scalar}}( 0, { 'dtype': 'int32' } );
> var out = {{alias}}.assign( x, y )
<ndarray>
<ndarray>[ 3 ]
> var bool = ( out === y )
true
> y.get()
3

See Also
--------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ interface CountTruthy {
*
* // Perform reduction:
* var out = countTruthy( x );
* // returns <ndarray>
*
* var v = out.get();
* // returns 5
* // returns <ndarray>[ 5 ]
*/
( x: ndarray, options?: Options ): int32ndarray; // FIXME: update once `int64` dtype support; may require adding support for an output `dtype` option

Expand Down Expand Up @@ -120,10 +117,7 @@ interface CountTruthy {
*
* // Perform reduction:
* var out = countTruthy.assign( x, y );
* // returns <ndarray>
*
* var v = out.get();
* // returns 5
* // returns <ndarray>[ 5 ]
*/
assign<T extends ndarray>( x: ndarray, y: T, options?: BaseOptions ): T;
}
Expand Down Expand Up @@ -158,10 +152,7 @@ interface CountTruthy {
*
* // Perform reduction:
* var out = countTruthy( x );
* // returns <ndarray>
*
* var v = out.get();
* // returns 5
* // returns <ndarray>[ 5 ]
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
Expand Down Expand Up @@ -190,10 +181,7 @@ interface CountTruthy {
*
* // Perform reduction:
* var out = countTruthy.assign( x, y );
* // returns <ndarray>
*
* var v = out.get();
* // returns 5
* // returns <ndarray>[ 5 ]
*/
declare var countTruthy: CountTruthy;

Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/ndarray/count-truthy/lib/assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ var validate = require( './validate.js' );
*
* // Perform reduction:
* var out = assign( x, y );
* // returns <ndarray>
*
* var v = out.get();
* // returns 5
* // returns <ndarray>[ 5 ]
*/
function assign( x, y, options ) {
var opts;
Expand Down
10 changes: 2 additions & 8 deletions lib/node_modules/@stdlib/ndarray/count-truthy/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@
*
* // Perform reduction:
* var out = countTruthy( x );
* // returns <ndarray>
*
* var v = out.get();
* // returns 5
* // returns <ndarray>[ 5 ]
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
Expand Down Expand Up @@ -78,10 +75,7 @@
*
* // Perform reduction:
* var out = countTruthy.assign( x, y );
* // returns <ndarray>
*
* var v = out.get();
* // returns 5
* // returns <ndarray>[ 5 ]
*/

// MODULES //
Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/ndarray/count-truthy/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ var DEFAULT_DTYPE = defaults.get( 'dtypes.integer_index' );
*
* // Perform reduction:
* var out = countTruthy( x );
* // returns <ndarray>
*
* var v = out.get();
* // returns 5
* // returns <ndarray>[ 5 ]
*/
function countTruthy( x, options ) {
var opts;
Expand Down