8000 docs: update examples · stdlib-js/stdlib@77957f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 77957f2

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: passed - 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 e05819a commit 77957f2

File tree

2 files changed

+25
-107
lines changed

2 files changed

+25
-107
lines changed

lib/node_modules/@stdlib/ndarray/includes/README.md

Lines changed: 23 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,15 @@ var includes = require( '@stdlib/ndarray/includes' );
4040

4141
Tests whether an [`ndarray`][@stdlib/ndarray/ctor] contains a specified value along one or more 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, 6.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 ] ], [ [ 5.0, 6.0 ] ] ] );
48+
// returns <ndarray>
6349

6450
// Perform reduction:
65-
var out = includes( x, 6.0 );
51+
var out = includes( x, 5.0 );
6652
// returns <ndarray>
6753

6854
var v = out.get();
@@ -82,106 +68,64 @@ The function accepts the following `options`:
8268

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

85-
<!-- eslint-disable max-len -->
86-
8771
```javascript
88-
var Float64Array = require( '@stdlib/array/float64' );
89-
var ndarray = require( '@stdlib/ndarray/ctor' );
72+
var array = require( '@stdlib/ndarray/array' );
9073
var ndarray2array = require( '@stdlib/ndarray/to-array' );
9174

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

10779
// Perform reduction:
108-
var out = includes( x, 6.0, {
80+
var out = includes( x, 5.0, {
10981
'dims': [ 1, 2 ]
11082
});
11183
// returns <ndarray>
11284

11385
var v = ndarray2array( out );
114-
// returns [ false, true, false ]
86+
// returns [ false, false, true ]
11587
```
11688

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

119-
<!-- eslint-disable max-len -->
120-
12191
```javascript
122-
var Float64Array = require( '@stdlib/array/float64' );
123-
var ndarray = require( '@stdlib/ndarray/ctor' );
92+
var array = require( '@stdlib/ndarray/array' );
12493
var ndarray2array = require( '@stdlib/ndarray/to-array' );
12594

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

14199
// Perform reduction:
142-
var out = includes( x, 6.0, {
100+
var out = includes( x, 5.0, {
143101
'dims': [ 1, 2 ],
144102
'keepdims': true
145103
});
146104
// returns <ndarray>
147105

148106
var v = ndarray2array( out );
149-
// returns [ [ [ false ] ], [ [ true ] ], [ [ false ] ] ]
107+
// returns [ [ [ false ] ], [ [ false ] ], [ [ true ] ] ]
150108
```
151109

152110
#### includes.assign( x, searchElement, out\[, options] )
153111

154112
Tests whether an [`ndarray`][@stdlib/ndarray/ctor] contains a specified value along one or more dimensions and assigns results to a provided output [`ndarray`][@stdlib/ndarray/ctor].
155113

156-
<!-- eslint-disable max-len -->
157-
158114
```javascript
159-
var Float64Array = require( '@stdlib/array/float64' );
160-
var ndarray = require( '@stdlib/ndarray/ctor' );
115+
var array = require( '@stdlib/ndarray/array' );
161116
var empty = require( '@stdlib/ndarray/empty' );
162117

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

178122
// Create an output ndarray:
179123
var y = empty( [], {
180124
'dtype': 'bool'
181125
});
182126

183127
// Perform reduction:
184-
var out = includes.assign( x, 6.0, y );
128+
var out = includes.assign( x, 5.0, y );
185129
// returns <ndarray>
186130

187131
var bool = ( out === y );
@@ -204,44 +148,30 @@ The function accepts the following `options`:
204148

205149
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.
206150

207-
<!-- eslint-disable max-len -->
208-
209151
```javascript
210-
var Float64Array = require( '@stdlib/array/float64' );
211-
var ndarray = require( '@stdlib/ndarray/ctor' );
152+
var array = require( '@stdlib/ndarray/array' );
212153
var empty = require( '@stdlib/ndarray/empty' );
213154
var ndarray2array = require( '@stdlib/ndarray/to-array' );
214155

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

230160
// Create an output ndarray:
231161
var y = empty( [ 3 ], {
232162
'dtype': 'bool'
233163
});
234164

235165
// Perform reduction:
236-
var out = includes.assign( x, 6.0, y, {
166+
var out = includes.assign( x, 5.0, y, {
237167
'dims': [ 1, 2 ]
238168
});
239169

240170
var bool = ( out === y );
241171
// returns true
242172

243173
var v = ndarray2array( y );
244-
// returns [ false, true, false ]
174+
// returns [ false, false, true ]
245175
```
246176

247177
</section>

lib/node_modules/@stdlib/ndarray/includes/docs/repl.txt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@
3333

3434
Examples
3535
--------
36-
> var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
37-
> var dt = 'float64';
38-
> var sh = [ 2, 2 ];
39-
> var sx = [ 2, 1 ];
40-
> var ox = 0;
41-
> var ord = 'row-major';
42-
> var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord );
36+
> var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] );
4337
> var y = {{alias}}( x, 3.0 )
4438
<ndarray>
4539
> y.get()
@@ -85,13 +79,7 @@
8579

8680
Examples
8781
--------
88-
> var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
89-
> var dt = 'float64';
90-
> var sh = [ 2, 2 ];
91-
> var sx = [ 2, 1 ];
92-
> var ox = 0;
93-
> var ord = 'row-major';
94-
> var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord );
82+
> var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] );
9583
> var y = {{alias:@stdlib/ndarray/from-scalar}}( false );
9684
> var out = {{alias}}.assign( x, 3.0, y )
9785
<ndarray>

0 commit comments

Comments
 (0)
0