Skip to content

Commit a1a33a8

Browse files
committed
docs: update examples
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent b2f3ce6 commit a1a33a8

File tree

1 file changed

+18
-88
lines changed
  • lib/node_modules/@stdlib/ndarray/count-truthy

1 file changed

+18
-88
lines changed

lib/node_modules/@stdlib/ndarray/count-truthy/README.md

Lines changed: 18 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,12 @@ var countTruthy = require( '@stdlib/ndarray/count-truthy' );
4040

4141
Counts the number of truthy elements along one or more [`ndarray`][@stdlib/ndarray/ctor] dimensions.
4242

43-
<!-- eslint-disable max-len -->
44-
4543
```javascript
46-
var Float64Array = require( '@stdlib/array/float64' );
47-
var ndarray = require( '@stdlib/ndarray/ctor' );
48-
49-
// Create a data buffer:
50-
var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
51-
52-
// Define the shape of the input array:
53-
var sh = [ 3, 1, 2 ];
54-
55-
// Define the array strides:
56-
var sx = [ 4, 4, 1 ];
57-
58-
// Define the index offset:
59-
var ox = 1;
44+
var array = require( '@stdlib/ndarray/array' );
6045

6146
// Create an input ndarray:
62-
var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
47+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] );
48+
// returns <ndarray>
6349

6450
// Perform operation:
6551
var out = countTruthy( x );
@@ -81,27 +67,13 @@ The function accepts the following `options`:
8167

8268
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.
8369

84-
<!-- eslint-disable max-len -->
85-
8670
```javascript
87-
var Float64Array = require( '@stdlib/array/float64' );
88-
var ndarray = require( '@stdlib/ndarray/ctor' );
71+
var array = require( '@stdlib/ndarray/array' );
8972
var ndarray2array = require( '@stdlib/ndarray/to-array' );
9073

91-
// Create a data buffer:
92-
var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
93-
94-
// Define the shape of the input array:
95-
var sh = [ 3, 1, 2 ];
96-
97-
// Define the array strides:
98-
var sx = [ 4, 4, 1 ];
99-
100-
// Define the index offset:
101-
var ox = 1;
102-
10374
// Create an input ndarray:
104-
var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
75+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] );
76+
// returns <ndarray>
10577

10678
// Perform operation:
10779
var out = countTruthy( x, {
@@ -110,32 +82,18 @@ var out = countTruthy( x, {
11082
// returns <ndarray>
11183

11284
var v = ndarray2array( out );
113-
// returns [ 2, 1, 2 ]
85+
// returns [ 2, 2, 1 ]
11486
```
11587

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

118-
<!-- eslint-disable max-len -->
119-
12090
```javascript
121-
var Float64Array = require( '@stdlib/array/float64' );
122-
var ndarray = require( '@stdlib/ndarray/ctor' );
91+
var array = require( '@stdlib/ndarray/array' );
12392
var ndarray2array = require( '@stdlib/ndarray/to-array' );
12493

125-
// Create a data buffer:
126-
var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
127-
128-
// Define the shape of the input array:
129-
var sh = [ 3, 1, 2 ];
130-
131-
// Define the array strides:
132-
var sx = [ 4, 4, 1 ];
133-
134-
// Define the index offset:
135-
var ox = 1;
136-
13794
// Create an input ndarray:
138-
var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
95+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] );
96+
// returns <ndarray>
13997

14098
// Perform operation:
14199
var out = countTruthy( x, {
@@ -145,34 +103,20 @@ var out = countTruthy( x, {
145103
// returns <ndarray>
146104

147105
var v = ndarray2array( out );
148-
// returns [ [ [ 2 ] ], [ [ 1 ] ], [ [ 2 ] ] ]
106+
// returns [ [ [ 2 ] ], [ [ 2 ] ], [ [ 1 ] ] ]
149107
```
150108

151109
#### countTruthy.assign( x, out\[, options] )
152110

153111
Counts the number of truthy elements along one or more [`ndarray`][@stdlib/ndarray/ctor] dimensions and assigns results to a provided output [`ndarray`][@stdlib/ndarray/ctor].
154112

155-
<!-- eslint-disable max-len -->
156-
157113
```javascript
158-
var Float64Array = require( '@stdlib/array/float64' );
159-
var ndarray = require( '@stdlib/ndarray/ctor' );
114+
var array = require( '@stdlib/ndarray/array' );
160115
var empty = require( '@stdlib/ndarray/empty' );
161116

162-
// Create a data buffer:
163-
var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
164-
165-
// Define the shape of the input array:
166-
var sh = [ 3, 1, 2 ];
167-
168-
// Define the array strides:
169-
var sx = [ 4, 4, 1 ];
170-
171-
// Define the index offset:
172-
var ox = 1;
173-
174117
// Create an input ndarray:
175-
var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
118+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] );
119+
// returns <ndarray>
176120

177121
// Create an output ndarray:
178122
var y = empty( [], {
@@ -202,28 +146,14 @@ The function accepts the following `options`:
202146

203147
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.
204148

205-
<!-- eslint-disable max-len -->
206-
207149
```javascript
208-
var Float64Array = require( '@stdlib/array/float64' );
209-
var ndarray = require( '@stdlib/ndarray/ctor' );
150+
var array = require( '@stdlib/ndarray/array' );
210151
var empty = require( '@stdlib/ndarray/empty' );
211152
var ndarray2array = require( '@stdlib/ndarray/to-array' );
212153

213-
// Create a data buffer:
214-
var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
215-
216-
// Define the shape of the input array:
217-
var sh = [ 3, 1, 2 ];
218-
219-
// Define the array strides:
220-
var sx = [ 4, 4, 1 ];
221-
222-
// Define the index offset:
223-
var ox = 1;
224-
225154
// Create an input ndarray:
226-
var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
155+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 0.0, 6.0 ] ] ] );
156+
// returns <ndarray>
227157

228158
// Create an output ndarray:
229159
var y = empty( [ 3 ], {
@@ -239,7 +169,7 @@ var bool = ( out === y );
239169
// returns true
240170

241171
var v = ndarray2array( y );
242-
// returns [ 2, 1, 2 ]
172+
// returns [ 2, 2, 1 ]
243173
```
244174

245175
</section>

0 commit comments

Comments
 (0)