Skip to content

Commit 826fc04

Browse files
committed
Auto-generated commit
1 parent 1ab9111 commit 826fc04

File tree

18 files changed

+588
-159
lines changed

18 files changed

+588
-159
lines changed

CHANGELOG.md

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

7-
## Unreleased (2025-06-10)
7+
## Unreleased (2025-07-05)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`4f78b17`](https://github.com/stdlib-js/stdlib/commit/4f78b17cee147cfd13285ec9445d17239d4b94df) - refactor and add protocol support to `stats/base/nanrange-by` [(#6440)](https://github.com/stdlib-js/stdlib/pull/6440)
14+
15+
</section>
16+
17+
<!-- /.features -->
18+
19+
<section class="issues">
20+
21+
### Closed Issues
22+
23+
This release closes the following issue:
24+
25+
[#5666](https://github.com/stdlib-js/stdlib/issues/5666)
26+
27+
</section>
28+
29+
<!-- /.issues -->
830

931
<section class="commits">
1032

1133
### Commits
1234

1335
<details>
1436

37+
- [`4f78b17`](https://github.com/stdlib-js/stdlib/commit/4f78b17cee147cfd13285ec9445d17239d4b94df) - **feat:** refactor and add protocol support to `stats/base/nanrange-by` [(#6440)](https://github.com/stdlib-js/stdlib/pull/6440) _(by Gautam Kaushik, Athan Reines, stdlib-bot, Gururaj Gurram)_
1538
- [`22f79a3`](https://github.com/stdlib-js/stdlib/commit/22f79a34bf0ba067ceb9b016b8e1717b265fbb3f) - **refactor:** update paths _(by Gururaj Gurram)_
1639
- [`e92388f`](https://github.com/stdlib-js/stdlib/commit/e92388f2e99794eed4be8908a2160e0ad9274321) - **refactor:** update paths _(by Gururaj Gurram)_
1740
- [`36e1bc3`](https://github.com/stdlib-js/stdlib/commit/36e1bc38710d07b84bf38c11cedaec4748b7faeb) - **refactor:** update paths _(by Aayush Khanna)_
@@ -28,9 +51,11 @@
2851

2952
### Contributors
3053

31-
A total of 3 people contributed to this release. Thank you to the following contributors:
54+
A total of 5 people contributed to this release. Thank you to the following contributors:
3255

3356
- Aayush Khanna
57+
- Athan Reines
58+
- Gautam Kaushik
3459
- Gururaj Gurram
3560
- Philipp Burckhardt
3661

CONTRIBUTORS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ Ali Salesi <ali_sal1381@yahoo.com>
2121
AlyAbdelmoneim <148393799+AlyAbdelmoneim@users.noreply.github.com>
2222
Aman Bhansali <bhansali.1@iitj.ac.in>
2323
AmanBhadkariya <140033975+AmanBhadkariya@users.noreply.github.com>
24+
Amisha Chhajed <136238836+amishhaa@users.noreply.github.com>
2425
Amit Jimiwal <amitjimiwal45@gmail.com>
2526
Annamalai Prabu <apfossdev@gmail.com>
2627
Anshu Kumar <132515490+anxhukumar@users.noreply.github.com>
2728
Anshu Kumar <contact.anshukumar@protonmail.com>
2829
Anudeep Sanapala <anudeep0306@gmail.com>
30+
Aryan Bhirud <112156883+AryanBhirud@users.noreply.github.com>
2931
Athan Reines <kgryte@gmail.com>
3032
Ayaka <73595362+USERSATOSHI@users.noreply.github.com>
3133
Bhavishy Agrawal <90029607+bhavishy2801@users.noreply.github.com>
@@ -35,6 +37,7 @@ Bryan Elee <rxbryn@gmail.com>
3537
Chinmay Joshi <86140365+JawHawk@users.noreply.github.com>
3638
Christopher Dambamuromo <chridam@gmail.com>
3739
Dan Rose <danoftheroses@gmail.com>
40+
Daniel Hernandez Gomez <156333015+dhernandeez13@users.noreply.github.com>
3841
Daniel Killenberger <daniel.killenberger@gmail.com>
3942
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
4043
Debashis Maharana <debashismaharana7854@gmail.com>
@@ -61,6 +64,7 @@ Girish Garg <garggirish2020@gmail.com>
6164
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
6265
Gunj Joshi <gunjjoshi8372@gmail.com>
6366
Gururaj Gurram <gururajgurram1512@gmail.com>
67+
Harishchandra Reddy <harish.7000@gmail.com>
6468
Haroon Rasheed <51189276+haroon26@users.noreply.github.com>
6569
Harsh <harshyadav6078@gmail.com>
6670
HarshaNP <96897754+GittyHarsha@users.noreply.github.com>
@@ -93,6 +97,7 @@ Krishnam Agarwal <83017176+888krishnam@users.noreply.github.com>
9397
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
9498
Kshitij-Dale <152467202+Kshitij-Dale@users.noreply.github.com>
9599
Lalit Narayan Yadav <162928571+LalitNarayanYadav@users.noreply.github.com>
100+
Lokesh Ranjan <lokesh.ranjan.phe23@itbhu.ac.in>
96101
Lovelin Dhoni J B <100030865+lovelindhoni@users.noreply.github.com>
97102
MANI <77221000+Eternity0207@users.noreply.github.com>
98103
Mahfuza Humayra Mohona <mhmohona@gmail.com>
@@ -193,11 +198,13 @@ Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
193198
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
194199
Yugal Kaushik <yugalkaushik14@gmail.com>
195200
Yuvi Mittal <128018763+yuvi-mittal@users.noreply.github.com>
201+
deepak427 <62477872+deepak427@users.noreply.github.com>
196202
devshree-bhati <147095250+devshree-bhati@users.noreply.github.com>
197203
ditsu <170345142+ditsus@users.noreply.github.com>
198204
ekambains <bainsinbusiness@gmail.com>
199205
fadiothman22 <48636283+fadiothman22@users.noreply.github.com>
200206
iraandrushko <71790513+iraandrushko@users.noreply.github.com>
207+
jsai28 <54253219+jsai28@users.noreply.github.com>
201208
lohithganni <116790357+lohithganni@users.noreply.github.com>
202209
olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com>
203210
pranav-1720 <123018993+pranav-1720@users.noreply.github.com>

README.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ To view installation and usage instructions specific to each branch build, be su
7171
var nanrangeBy = require( '@stdlib/stats-base-nanrange-by' );
7272
```
7373

74-
#### nanrangeBy( N, x, stride, clbk\[, thisArg] )
74+
#### nanrangeBy( N, x, strideX, clbk\[, thisArg] )
7575

76-
Calculates the [range][range] of strided array `x` via a callback function, ignoring `NaN` values.
76+
Computes the [range][range] of a strided array via a callback function, ignoring `NaN` values.
7777

7878
```javascript
7979
function accessor( v ) {
@@ -90,7 +90,7 @@ The function has the following parameters:
9090

9191
- **N**: number of indexed elements.
9292
- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions).
93-
- **stride**: index increment.
93+
- **strideX**: stride length.
9494
- **clbk**: callback function.
9595
- **thisArg**: execution context (_optional_).
9696

@@ -122,27 +122,23 @@ var cnt = context.count;
122122
// returns 10
123123
```
124124

125-
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element
125+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element
126126

127127
```javascript
128-
var floor = require( '@stdlib/math-base-special-floor' );
129-
130128
function accessor( v ) {
131129
return v * 2.0;
132130
}
133131

134132
var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0, NaN, NaN ];
135-
var N = floor( x.length / 2 );
136133

137-
var v = nanrangeBy( N, x, 2, accessor );
134+
var v = nanrangeBy( 5, x, 2, accessor );
138135
// returns 12.0
139136
```
140137

141138
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
142139

143140
```javascript
144141
var Float64Array = require( '@stdlib/array-float64' );
145-
var floor = require( '@stdlib/math-base-special-floor' );
146142

147143
function accessor( v ) {
148144
return v * 2.0;
@@ -153,16 +149,15 @@ var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
153149

154150
// Create an offset view...
155151
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
156-
var N = floor( x0.length/2 );
157152

158153
// Access every other element...
159-
var v = nanrangeBy( N, x1, 2, accessor );
154+
var v = nanrangeBy( 3, x1, 2, accessor );
160155
// returns 8.0
161156
```
162157

163-
#### nanrangeBy.ndarray( N, x, stride, offset, clbk\[, thisArg] )
158+
#### nanrangeBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] )
164159

165-
Calculates the [range][range] of strided array `x` via a callback function, ignoring `NaN` values and using alternative indexing semantics.
160+
Computes the [range][range] of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics.
166161

167162
```javascript
168163
function accessor( v ) {
@@ -177,9 +172,9 @@ var v = nanrangeBy.ndarray( x.length, x, 1, 0, accessor );
177172

178173
The function has the following additional parameters:
179174

180-
- **offset**: starting index.
175+
- **offsetX**: starting index.
181176

182-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x`
177+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x`
183178

184179
```javascript
185180
function accessor( v ) {
@@ -204,6 +199,7 @@ var v = nanrangeBy.ndarray( 3, x, 1, x.length-3, accessor );
204199
- A provided callback function should return a numeric value.
205200
- If a provided callback function returns `NaN`, the value is ignored.
206201
- If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is ignored.
202+
- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array-base/accessor`][@stdlib/array/base/accessor]).
207203
- When possible, prefer using [`dnanrange`][@stdlib/stats/strided/dnanrange], [`snanrange`][@stdlib/stats/strided/snanrange], and/or [`nanrange`][@stdlib/stats/base/nanrange], as, depending on the environment, these interfaces are likely to be significantly more performant.
208204

209205
</section>
@@ -217,23 +213,23 @@ var v = nanrangeBy.ndarray( 3, x, 1, x.length-3, accessor );
217213
<!-- eslint no-undef: "error" -->
218214

219215
```javascript
220-
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' );
221-
var randu = require( '@stdlib/random-base-randu' );
216+
var uniform = require( '@stdlib/random-base-uniform' );
222217
var filledarrayBy = require( '@stdlib/array-filled-by' );
218+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
223219
var nanrangeBy = require( '@stdlib/stats-base-nanrange-by' );
224220

225-
function fill() {
226-
if ( randu() < 0.2 ) {
221+
function rand() {
222+
if ( bernoulli( 0.8 ) < 0.2 ) {
227223
return NaN;
228224
}
229-
return discreteUniform( -50, 50 );
225+
return uniform( -50.0, 50.0 );
230226
}
231227

232228
function accessor( v ) {
233229
return v * 2.0;
234230
}
235231

236-
var x = filledarrayBy( 10, 'float64', fill );
232+
var x = filledarrayBy( 10, 'float64', rand );
237233
console.log( x );
238234

239235
var v = nanrangeBy( x.length, x, 1, accessor );
@@ -341,6 +337,8 @@ Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
341337

342338
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
343339

340+
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/array-base-accessor
341+
344342
<!-- <related-links> -->
345343

346344
[@stdlib/stats/strided/dnanrange]: https://github.com/stdlib-js/stats-strided-dnanrange

benchmark/benchmark.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
24+
var uniform = require( '@stdlib/random-base-uniform' );
25+
var filledarrayBy = require( '@stdlib/array-filled-by' );
26+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
2527
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2628
var pow = require( '@stdlib/math-base-special-pow' );
2729
var pkg = require( './../package.json' ).name;
28-
var nanrangeBy = require( './../lib/nanrange_by.js' );
30+
var nanrangeBy = require( './../lib/main.js' );
2931

3032

3133
// FUNCTIONS //
@@ -41,6 +43,19 @@ function accessor( value ) {
4143
return value * 2.0;
4244
}
4345

46+
/**
47+
* Returns a random number.
48+
*
49+
* @private
50+
* @returns {number} random number
51+
*/
52+
function rand() {
53+
if ( bernoulli( 0.8 ) < 1 ) {
54+
return NaN;
55+
}
56+
return uniform( -50.0, 50.0 );
57+
}
58+
4459
/**
4560
* Create a benchmark function.
4661
*
@@ -49,17 +64,7 @@ function accessor( value ) {
4964
* @returns {Function} benchmark function
5065
*/
5166
function createBenchmark( len ) {
52-
var x;
53-
var i;
54-
55-
x = [];
56-
for ( i = 0; i < len; i++ ) {
57-
if ( randu() < 0.2 ) {
58-
x.push( NaN );
59-
} else {
60-
x.push( ( randu()*20.0 ) - 10.0 );
61-
}
62-
}
67+
var x = filledarrayBy( len, 'generic', rand );
6368
return benchmark;
6469

6570
function benchmark( b ) {

benchmark/benchmark.ndarray.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
24+
var uniform = require( '@stdlib/random-base-uniform' );
25+
var filledarrayBy = require( '@stdlib/array-filled-by' );
26+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
2527
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2628
var pow = require( '@stdlib/math-base-special-pow' );
2729
var pkg = require( './../package.json' ).name;
@@ -41,6 +43,19 @@ function accessor( value ) {
4143
return value * 2.0;
4244
}
4345

46+
/**
47+
* Returns a random number.
48+
*
49+
* @private
50+
* @returns {number} random number
51+
*/
52+
function rand() {
53+
if ( bernoulli( 0.8 ) < 1 ) {
54+
return NaN;
55+
}
56+
return uniform( -50.0, 50.0 );
57+
}
58+
4459
/**
4560
* Create a benchmark function.
4661
*
@@ -49,17 +64,7 @@ function accessor( value ) {
4964
* @returns {Function} benchmark function
5065
*/
5166
function createBenchmark( len ) {
52-
var x;
53-
var i;
54-
55-
x = [];
56-
for ( i = 0; i < len; i++ ) {
57-
if ( randu() < 0.2 ) {
58-
x.push( NaN );
59-
} else {
60-
x.push( ( randu()*20.0 ) - 10.0 );
61-
}
62-
}
67+
var x = filledarrayBy( len, 'generic', rand );
6368
return benchmark;
6469

6570
function benchmark( b ) {

dist/index.js

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)