Skip to content

Commit 07a47ca

Browse files
committed
Auto-generated commit
1 parent 7d8eeb9 commit 07a47ca

File tree

95 files changed

+15217
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+15217
-1
lines changed

CHANGELOG.md

Lines changed: 24 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-04-18)
7+
## Unreleased (2025-04-19)
88

99
<section class="packages">
1010

@@ -533,6 +533,28 @@ This release closes the following issue:
533533

534534
<!-- /.package -->
535535

536+
<section class="package" id="ndarray-base-every-by-unreleased">
537+
538+
#### [@stdlib/ndarray/base/every-by](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/every-by)
539+
540+
<details>
541+
542+
<section class="features">
543+
544+
##### Features
545+
546+
- [`00450cc`](https://github.com/stdlib-js/stdlib/commit/00450cc5a91760e1d2aba09bb942bb0a84bc9157) - add `ndarray/base/every-by` [(#6667)](https://github.com/stdlib-js/stdlib/pull/6667)
547+
548+
</section>
549+
550+
<!-- /.features -->
551+
552+
</details>
553+
554+
</section>
555+
556+
<!-- /.package -->
557+
536558
<section class="package" id="ndarray-base-expand-dimensions-unreleased">
537559

538560
#### [@stdlib/ndarray/base/expand-dimensions](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/expand-dimensions)
@@ -1565,6 +1587,7 @@ A total of 13 people contributed to this release. Thank you to the following con
15651587

15661588
<details>
15671589

1590+
- [`00450cc`](https://github.com/stdlib-js/stdlib/commit/00450cc5a91760e1d2aba09bb942bb0a84bc9157) - **feat:** add `ndarray/base/every-by` [(#6667)](https://github.com/stdlib-js/stdlib/pull/6667) _(by Muhammad Haris, Athan Reines)_
15681591
- [`f7bb91c`](https://github.com/stdlib-js/stdlib/commit/f7bb91c2aa3b31c86ddd57cfd3396632c78d42c0) - **fix:** ensure support for zero-dimensional shapes _(by Athan Reines)_
15691592
- [`046926b`](https://github.com/stdlib-js/stdlib/commit/046926b9a0ad4643802944ef110b1cfe1eb488c9) - **fix:** ensure support for zero-dimensional shapes _(by Athan Reines)_
15701593
- [`b1d96c9`](https://github.com/stdlib-js/stdlib/commit/b1d96c95fce3e8692ec6cbb4436eacd1943a5528) - **refactor:** use assertion utility _(by Athan Reines)_

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ Yuvi Mittal <128018763+yuvi-mittal@users.noreply.github.com>
181181
ditsu <170345142+ditsus@users.noreply.github.com>
182182
ekambains <bainsinbusiness@gmail.com>
183183
fadiothman22 <48636283+fadiothman22@users.noreply.github.com>
184+
iraandrushko <71790513+iraandrushko@users.noreply.github.com>
184185
lohithganni <116790357+lohithganni@users.noreply.github.com>
185186
olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com>
186187
pranav-1720 <123018993+pranav-1720@users.noreply.github.com>

base/every-by/README.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# everyBy
22+
23+
> Test whether all elements in an ndarray pass a test implemented by a predicate function.
24+
25+
<section class="intro">
26+
27+
</section>
28+
29+
<!-- /.intro -->
30+
31+
<section class="usage">
32+
33+
## Usage
34+
35+
```javascript
36+
var everyBy = require( '@stdlib/ndarray/base/every-by' );
37+
```
38+
39+
#### everyBy( arrays, predicate\[, thisArg] )
40+
41+
Tests whether all elements in an ndarray pass a test implemented by a predicate function.
42+
43+
<!-- eslint-disable max-len -->
44+
45+
```javascript
46+
var Float64Array = require( '@stdlib/array/float64' );
47+
48+
function clbk( value ) {
49+
return value > 0.0;
50+
}
51+
52+
// Create a data buffer:
53+
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 ] );
54+
55+
// Define the shape of the input array:
56+
var shape = [ 3, 1, 2 ];
57+
58+
// Define the array strides:
59+
var sx = [ 4, 4, 1 ];
60+
61+
// Define the index offset:
62+
var ox = 0;
63+
64+
// Create the input ndarray-like object:
65+
var x = {
66+
'dtype': 'float64',
67+
'data': xbuf,
68+
'shape': shape,
69+
'strides': sx,
70+
'offset': ox,
71+
'order': 'row-major'
72+
};
73+
74+
// Test elements:
75+
var out = everyBy( [ x ], clbk );
76+
// returns true
77+
```
78+
79+
The function accepts the following arguments:
80+
81+
- **arrays**: array-like object containing an input ndarray.
82+
- **predicate**: predicate function.
83+
- **thisArg**: predicate function execution context (_optional_).
84+
85+
The provided ndarray should be an `object` with the following properties:
86+
87+
- **dtype**: data type.
88+
- **data**: data buffer.
89+
- **shape**: dimensions.
90+
- **strides**: stride lengths.
91+
- **offset**: index offset.
92+
- **order**: specifies whether an ndarray is row-major (C-style) or column major (Fortran-style).
93+
94+
The predicate function is provided the following arguments:
95+
96+
- **value**: current array element.
97+
- **indices**: current array element indices.
98+
- **arr**: the input ndarray.
99+
100+
To set the predicate function execution context, provide a `thisArg`.
101+
102+
<!-- eslint-disable no-invalid-this, max-len -->
103+
104+
```javascript
105+
var Float64Array = require( '@stdlib/array/float64' );
106+
107+
function clbk( value ) {
108+
this.count += 1;
109+
return value > 0.0;
110+
}
111+
112+
// Create a data buffer:
113+
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 ] );
114+
115+
// Define the shape of the input array:
116+
var shape = [ 3, 1, 2 ];
117+
118+
// Define the array strides:
119+
var sx = [ 4, 4, 1 ];
120+
121+
// Define the index offset:
122+
var ox = 0;
123+
124+
// Create the input ndarray-like object:
125+
var x = {
126+
'dtype': 'float64',
127+
'data': xbuf,
128+
'shape': shape,
129+
'strides': sx,
130+
'offset': ox,
131+
'order': 'row-major'
132+
};
133+
134+
var ctx = {
135+
'count': 0
136+
};
137+
138+
// Test elements:
139+
var out = everyBy( [ x ], clbk, ctx );
140+
// returns true
141+
142+
var count = ctx.count;
143+
// returns 6
144+
```
145+
146+
</section>
147+
148+
<!-- /.usage -->
149+
150+
<section class="notes">
151+
152+
## Notes
153+
154+
- For very high-dimensional ndarrays which are non-contiguous, one should consider copying the underlying data to contiguous memory before performing the operation in order to achieve better performance.
155+
- If provided an empty ndarray, the function returns `true`.
156+
157+
</section>
158+
159+
<!-- /.notes -->
160+
161+
<section class="examples">
162+
163+
## Examples
164+
165+
<!-- eslint no-undef: "error" -->
166+
167+
```javascript
168+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
169+
var ndarray2array = require( '@stdlib/ndarray/base/to-array' );
170+
var everyBy = require( '@stdlib/ndarray/base/every-by' );
171+
172+
function clbk( value ) {
173+
return value > 0;
174+
}
175+
176+
var x = {
177+
'dtype': 'generic',
178+
'data': discreteUniform( 10, -2, 10, {
179+
'dtype': 'generic'
180+
}),
181+
'shape': [ 5, 2 ],
182+
'strides': [ 2, 1 ],
183+
'offset': 0,
184+
'order': 'row-major'
185+
};
186+
console.log( ndarray2array( x.data, x.shape, x.strides, x.offset, x.order ) );
187+
188+
var out = everyBy( [ x ], clbk );
189+
console.log( out );
190+
```
191+
192+
</section>
193+
194+
<!-- /.examples -->
195+
196+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
197+
198+
<section class="related">
199+
200+
</section>
201+
202+
<!-- /.related -->
203+
204+
<section class="links">
205+
206+
</section>
207+
208+
<!-- /.links -->

0 commit comments

Comments
 (0)