8000 Auto-generated commit · stdlib-js/ndarray-includes@29722be · GitHub
[go: up one dir, main page]

Skip to content

Commit 29722be

Browse files
committed
Auto-generated commit
1 parent f9c10b3 commit 29722be

File tree

5 files changed

+32
-109
lines changed

5 files changed

+32
-109
lines changed

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-05-12)
7+
## Unreleased (2025-05-31)
88

99
<section class="features">
1010

@@ -33,6 +33,7 @@
3333

3434
<details>
3535

36+
- [`77957f2`](https://github.com/stdlib-js/stdlib/commit/77957f2a9bb3d815b7bc92d07d3f6fdebce44f33) - **docs:** update examples _(by Athan Reines)_
3637
- [`07710f8`](https://github.com/stdlib-js/stdlib/commit/07710f849133f4414b37a19a96fb3ccdad7538d5) - **fix:** check for duplicate indices _(by Athan Reines)_
3738
- [`dcd9428`](https://github.com/stdlib-js/stdlib/commit/dcd9428900fbd2bdfe3505e71fa00ccd08a7efce) - **refactor:** fix argument _(by Athan Reines)_
3839
- [`605c582`](https://github.com/stdlib-js/stdlib/commit/605c5828fe6efeae442d8df17d29404d2acb759f) - **fix:** update error message _(by Athan Reines)_

CONTRIBUTORS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ Ryan Seal <splrk@users.noreply.github.com>
146146
Rylan Yang <137365285+rylany27@users.noreply.github.com>
147147
SAHIL KUMAR <168997976+sahilk45@users.noreply.github.com>
148148
SHIVAM YADAV <120725381+Shivam-1827@users.noreply.github.com>
149+
Sachin Raj <120590207+schnrj@users.noreply.github.com>
149150
Sahil Goyal <87982509+sahil20021008@users.noreply.github.com>
150151
Sai Avinash <120403424+nasarobot@users.noreply.github.com>
151152
Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com>
@@ -166,10 +167,14 @@ Spandan Barve <contact@marsian.dev>
166167
Stephannie Jiménez Gacha <steff456@hotmail.com>
167168
Suhaib Ilahi <suhaib.elahi87@gmail.com>
168169
Suraj Kumar <125961509+kumarsuraj212003@users.noreply.github.com>
170+
Swapnil Hajare <69076366+Swapnil-2502@users.noreply.github.com>
169171
Tanishq Ahuja <68651083+TheGEN1U5@users.noreply.github.com>
170172
Tirtadwipa Manunggal <tirtadwipa.manunggal@gmail.com>
171173
Tudor Pagu <104032457+tudor-pagu@users.noreply.github.com>
172174
Tufailahmed Bargir <142114244+Tufailahmed-Bargir@users.noreply.github.com>
175+
Tushar Bhardwaj <155543597+TusharBhardwaj441@users.noreply.github.com>
176+
Uday Kakade <141299403+udaykakade25@users.noreply.github.com>
177+
Ujjwal Kirti <64329707+ujjwalkirti@users.noreply.github.com>
173178
Utkarsh <http://utkarsh11105@gmail.com>
174179
Utkarsh Raj <rajutkarsh2505@gmail.com>
175180
UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>

README.md

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

7474
Tests whether an [`ndarray`][@stdlib/ndarray/ctor] contains a specified value along one or more dimensions.
7575

76-
<!-- eslint-disable max-len -->
77-
7876
```javascript
79-
var Float64Array = require( '@stdlib/array-float64' );
80-
var ndarray = require( '@stdlib/ndarray-ctor' );
81-
82-
// Create a data buffer:
83-
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 ] );
84-
85-
// Define the shape of the input array:
86-
var sh = [ 3, 1, 2 ];
87-
88-
// Define the array strides:
89-
var sx = [ 4, 4, 1 ];
90-
91-
// Define the index offset:
92-
var ox = 1;
77+
var array = require( '@stdlib/ndarray-array' );
9378

9479
// Create an input ndarray:
95-
var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
80+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
81+
// returns <ndarray>
9682

9783
// Perform reduction:
98-
var out = includes( x, 6.0 );
84+
var out = includes( x, 5.0 );
9985
// returns <ndarray>
10086

10187
var v = out.get();
@@ -115,106 +101,64 @@ The function accepts the following `options`:
115101

116102
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.
117103

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

125-
// Create a data buffer:
126-
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 ] );
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-
137108
// Create an input ndarray:
138-
var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
109+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] 4B12 ] ] );
110+
// returns <ndarray>
139111

140112
// Perform reduction:
141-
var out = includes( x, 6.0, {
113+
var out = includes( x, 5.0, {
142114
'dims': [ 1, 2 ]
143115
});
144116
// returns <ndarray>
145117

146118
var v = ndarray2array( out );
147-
// returns [ false, true, false ]
119+
// returns [ false, false, true ]
148120
```
149121

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

152-
<!-- eslint-disable max-len -->
153-
154124
```javascript
155-
var Float64Array = require( '@stdlib/array-float64' );
156-
var ndarray = require( '@stdlib/ndarray-ctor' );
125+
var array = require( '@stdlib/ndarray-array' );
157126
var ndarray2array = require( '@stdlib/ndarray-to-array' );
158127

159-
// Create a data buffer:
160-
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 ] );
161-
162-
// Define the shape of the input array:
163-
var sh = [ 3, 1, 2 ];
164-
165-
// Define the array strides:
166-
var sx = [ 4, 4, 1 ];
167-
168-
// Define the index offset:
169-
var ox = 1;
170-
171128
// Create an input ndarray:
172-
var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
129+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
130+
// returns <ndarray>
173131

174132
// Perform reduction:
175-
var out = includes( x, 6.0, {
133+
var out = includes( x, 5.0, {
176134
'dims': [ 1, 2 ],
177135
'keepdims': true
178136
});
179137
// returns <ndarray>
180138

181139
var v = ndarray2array( out );
182-
// returns [ [ [ false ] ], [ [ true ] ], [ [ false ] ] ]
140+
// returns [ [ [ false ] ], [ [ false ] ], [ [ true ] ] ]
183141
```
184142

185143
#### includes.assign( x, searchElement, out\[, options] )
186144

187145
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].
188146

189-
<!-- eslint-disable max-len -->
190-
191147
```javascript
192-
var Float64Array = require( '@stdlib/array-float64' );
193-
var ndarray = require( '@stdlib/ndarray-ctor' );
148+
var array = require( '@stdlib/ndarray-array' );
194149
var empty = require( '@stdlib/ndarray-empty' );
195150

196-
// Create a data buffer:
197-
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 ] );
198-
199-
// Define the shape of the input array:
200-
var sh = [ 3, 1, 2 ];
201-
202-
// Define the array strides:
203-
var sx = [ 4, 4, 1 ];
204-
205-
// Define the index offset:
206-
var ox = 1;
207-
208151
// Create an input ndarray:
209-
var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
152+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
153+
// returns <ndarray>
210154

211155
// Create an output ndarray:
212156
var y = empty( [], {
213157
'dtype': 'bool'
214158
});
215159

216160
// Perform reduction:
217-
var out = includes.assign( x, 6.0, y );
161+
var out = includes.assign( x, 5.0, y );
218162
// returns <ndarray>
219163

220164
var bool = ( out === y );
@@ -237,44 +181,30 @@ The function accepts the following `options`:
237181

238182
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.
239183

240-
<!-- eslint-disable max-len -->
241-
242184
```javascript
243-
var Float64Array = require( '@stdlib/array-float64' );
244-
var ndarray = require( '@stdlib/ndarray-ctor' );
185+
var array = require( '@stdlib/ndarray-array' );
245186
var empty = require( '@stdlib/ndarray-empty' );
246187
var ndarray2array = require( '@stdlib/ndarray-to-array' );
247188

248-
// Create a data buffer:
249-
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 ] );
250-
251-
// Define the shape of the input array:
252-
var sh = [ 3, 1, 2 ];
253-
254-
// Define the array strides:
255-
var sx = [ 4, 4, 1 ];
256-
257-
// Define the index offset:
258-
var ox = 1;
259-
260189
// Create an input ndarray:
261-
var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
190+
var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
191+
// returns <ndarray>
262192

263193
// Create an output ndarray:< 5AE0 /span>
264194
var y = empty( [ 3 ], {
265195
'dtype': 'bool'
266196
});
267197

268198
// Perform reduction:
269-
var out = includes.assign( x, 6.0, y, {
199+
var out = includes.assign( x, 5.0, y, {
270200
'dims': [ 1, 2 ]
271201
});
272202

273203
var bool = ( out === y );
274204
// returns true
275205

276206
var v = ndarray2array( y );
277-
// returns [ false, true, false ]
207+
// returns [ false, false, true ]
278208
```
279209

280210
</section>

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