From 7c0f34299f3d8021bb18c5d9408254ac8952029c Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sat, 29 Mar 2025 15:21:08 +0530
Subject: [PATCH 01/36] Create accessors.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../stats/base/nanrange-by/lib/accessors.js | 103 ++++++++++++++++++
1 file changed, 103 insertions(+)
create mode 100644 lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
new file mode 100644
index 000000000000..0d623cebee47
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
@@ -0,0 +1,103 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+
+// MAIN //
+
+/**
+* Calculates the range of a strided array via a callback function, ignoring `NaN` values.
+*
+* @param {PositiveInteger} N - number of indexed elements
+* @param {Collection} x - input array/collection
+* @param {integer} stride - index increment
+* @param {NonNegativeInteger} offset - starting index
+* @param {Callback} clbk - callback
+* @param {*} [thisArg] - execution context
+* @returns {number} range
+*
+* @example
+* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ];
+*
+* function accessor( v ) {
+* return v * 2.0;
+* }
+*
+* var v = nanrangeBy( x.length, x, 1, 0, accessor );
+* // returns 18.0
+*/
+function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
+ var xbuf;
+ var get;
+ var max;
+ var min;
+ var ix;
+ var v;
+ var i;
+
+ // Cache reference to array data:
+ xbuf = x.data;
+
+ // Cache a reference to the element accessor:
+ get = x.accessors[0];
+ if ( N <= 0 ) {
+ return NaN;
+ }
+ if ( N === 1 || strideX === 0 ) {
+ v = clbk.call( thisArg, get( xbuf, 0 ), 0, 0, x );
+ if ( v === void 0 || isnan( v ) ) {
+ return NaN;
+ }
+ return 0.0;
+ }
+ ix = offsetX;
+ for ( i = 0; i < N; i++ ) {
+ min = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
+ if ( min === min && min !== void 0 ) {
+ break;
+ }
+ ix += strideX;
+ }
+ if ( i === N ) {
+ return NaN;
+ }
+ max = min;
+ i += 1;
+ for ( i; i < N; i++ ) {
+ ix += strideX;
+ v = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
+ if ( v === void 0 || isnan( v ) ) {
+ continue;
+ }
+ if ( v < min ) {
+ min = v;
+ } else if ( v > max ) {
+ max = v;
+ }
+ }
+ return max - min;
+}
+
+
+// EXPORTS //
+
+module.exports = nanrangeBy;
From 14f0a5fc856c56c6c337e16fdc581ef12b96dfd2 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:25:01 +0530
Subject: [PATCH 02/36] Update accessors.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../@stdlib/stats/base/nanrange-by/lib/accessors.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
index 0d623cebee47..1b6eb6bd0443 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2025 The Stdlib Authors.
+* Copyright (c) 2025 The Stdlib Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
From 7b487b1107d02e3f88f3ec1ad7823b6e0b4b7c83 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:28:23 +0530
Subject: [PATCH 03/36] Update nanrange_by.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../stats/base/nanrange-by/lib/nanrange_by.js | 57 ++-----------------
1 file changed, 6 insertions(+), 51 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js
index b7b9dd146f9f..1aec8c0ebcae 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@
// MODULES //
-var isnan = require( '@stdlib/math/base/assert/is-nan' );
-
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
// MAIN //
@@ -30,7 +30,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
*
* @param {PositiveInteger} N - number of indexed elements
* @param {Collection} x - input array/collection
-* @param {integer} stride - index increment
+* @param {integer} strideX - index increment
* @param {Callback} clbk - callback
* @param {*} [thisArg] - execution context
* @returns {number} range
@@ -45,53 +45,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
* var v = nanrangeBy( x.length, x, 1, accessor );
* // returns 18.0
*/
-function nanrangeBy( N, x, stride, clbk, thisArg ) {
- var max;
- var min;
- var ix;
- var v;
- var i;
-
- if ( N <= 0 ) {
- return NaN;
- }
- if ( N === 1 || stride === 0 ) {
- v = clbk.call( thisArg, x[ 0 ], 0, 0, x );
- if ( v === void 0 || isnan( v ) ) {
- return NaN;
- }
- return 0.0;
- }
- if ( stride < 0 ) {
- ix = (1-N) * stride;
- } else {
- ix = 0;
- }
- for ( i = 0; i < N; i++ ) {
- min = clbk.call( thisArg, x[ ix ], i, ix, x );
- if ( min === min && min !== void 0 ) {
- break;
- }
- ix += stride;
- }
- if ( i === N ) {
- return NaN;
- }
- max = min;
- i += 1;
- for ( i; i < N; i++ ) {
- ix += stride;
- v = clbk.call( thisArg, x[ ix ], i, ix, x );
- if ( v === void 0 || isnan( v ) ) {
- continue;
- }
- if ( v < min ) {
- min = v;
- } else if ( v > max ) {
- max = v;
- }
- }
- return max - min;
+function nanrangeBy( N, x, strideX, clbk, thisArg ) {
+ return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk , thisArg);
}
From af57abf347218d419876a04eeeb9e9aaf4ebb97d Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:28:53 +0530
Subject: [PATCH 04/36] Update ndarray.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../stats/base/nanrange-by/lib/ndarray.js | 23 ++++++++++++-------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
index 8d7bcbae67df..2365cd790e67 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* Copyright (c) 2025 The Stdlib Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
// MODULES //
var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
+var accessors = require( './accessors.js' );
// MAIN //
@@ -30,8 +32,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
*
* @param {PositiveInteger} N - number of indexed elements
* @param {Collection} x - input array/collection
-* @param {integer} stride - index increment
-* @param {NonNegativeInteger} offset - starting index
+* @param {integer} strideX - index increment
+* @param {NonNegativeInteger} offsetX - starting index
* @param {Callback} clbk - callback
* @param {*} [thisArg] - execution context
* @returns {number} range
@@ -46,9 +48,10 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
* var v = nanrangeBy( x.length, x, 1, 0, accessor );
* // returns 18.0
*/
-function nanrangeBy( N, x, stride, offset, clbk, thisArg ) {
+function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
var max;
var min;
+ var o;
var ix;
var v;
var i;
@@ -56,20 +59,24 @@ function nanrangeBy( N, x, stride, offset, clbk, thisArg ) {
if ( N <= 0 ) {
return NaN;
}
- if ( N === 1 || stride === 0 ) {
+ o = arraylike2object( x );
+ if ( o.accessorProtocol ) {
+ return accessors( N, o, strideX, offsetX, clbk, thisArg );
+ }
+ if ( N === 1 || strideX === 0 ) {
v = clbk.call( thisArg, x[ 0 ], 0, 0, x );
if ( v === void 0 || isnan( v ) ) {
return NaN;
}
return 0.0;
}
- ix = offset;
+ ix = offsetX;
for ( i = 0; i < N; i++ ) {
min = clbk.call( thisArg, x[ ix ], i, ix, x );
if ( min === min && min !== void 0 ) {
break;
}
- ix += stride;
+ ix += strideX;
}
if ( i === N ) {
return NaN;
@@ -77,7 +84,7 @@ function nanrangeBy( N, x, stride, offset, clbk, thisArg ) {
max = min;
i += 1;
for ( i; i < N; i++ ) {
- ix += stride;
+ ix += strideX;
v = clbk.call( thisArg, x[ ix ], i, ix, x );
if ( v === void 0 || isnan( v ) ) {
continue;
From 8f40fa3941e14f8103dd3ea5e4c1b83d93493a10 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:29:31 +0530
Subject: [PATCH 05/36] Update test.nanrange_by.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../base/nanrange-by/test/test.nanrange_by.js | 183 +++++++++++++++++-
1 file changed, 182 insertions(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js
index ce1e4d8fe3ed..9d72025be10d 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js
@@ -22,6 +22,7 @@
var tape = require( 'tape' );
var floor = require( '@stdlib/math/base/special/floor' );
+var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
var Float64Array = require( '@stdlib/array/float64' );
@@ -87,6 +88,42 @@ tape( 'the function calculates the range of a strided array via a callback funct
t.end();
});
+tape( 'the function calculates the range of a strided array via a callback function, ignoring NaN values (accessor)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, NaN, 3.0 ];
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ t.strictEqual( v, 18.0, 'returns expected value' );
+
+ x = [ -4.0, NaN, -5.0 ];
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ t.strictEqual( v, 2.0, 'returns expected value' );
+
+ x = [ -0.0, 0.0, NaN, -0.0 ];
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );
+
+ x = [ NaN ];
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ x = [ NaN, NaN ];
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ x = new Array( 5 ); // sparse array
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ x = new Array( 5 ); // sparse array
+ x[ 2 ] = 1.0;
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) {
var x;
var v;
@@ -102,6 +139,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
t.end();
});
+tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = nanrangeBy( 0, toAccessorArray(x), 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ v = nanrangeBy( -1, toAccessorArray(x), 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) {
var x;
var v;
@@ -117,6 +169,21 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun
t.end();
});
+tape( 'if provided an `N` parameter equal to `1`, the function returns `0` (accessors)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = nanrangeBy( 1, toAccessorArray(x), 1, accessor );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ x = new Array( 1 ); // sparse array
+ v = nanrangeBy( 1, toAccessorArray(x), 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
tape( 'the function supports a `stride` parameter', function test( t ) {
var N;
@@ -143,6 +210,31 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
t.end();
});
+tape( 'the function supports a `stride` parameter (accessors)', function test( t ) {
+ var N;
+ var x;
+ var v;
+
+ x = [
+ 1.0, // 0
+ 2.0,
+ 2.0, // 1
+ -7.0,
+ -2.0, // 2
+ 3.0,
+ 4.0, // 3
+ 2.0,
+ NaN, // 4
+ NaN
+ ];
+
+ N = floor( x.length / 2 );
+ v = nanrangeBy( N, toAccessorArray(x), 2, accessor );
+
+ t.strictEqual( v, 12.0, 'returns expected value' );
+ t.end();
+});
+
tape( 'the function supports a negative `stride` parameter', function test( t ) {
var N;
var x;
@@ -168,13 +260,38 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
t.end();
});
+tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) {
+ var N;
+ var x;
+ var v;
+
+ x = [
+ NaN, // 4
+ NaN,
+ 1.0, // 3
+ 2.0,
+ 2.0, // 2
+ -7.0,
+ -2.0, // 1
+ 3.0,
+ 4.0, // 0
+ 2.0
+ ];
+
+ N = floor( x.length / 2 );
+ v = nanrangeBy( N, toAccessorArray(x), -2, accessor );
+
+ t.strictEqual( v, 12.0, 'returns expected value' );
+ t.end();
+});
+
tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', function test( t ) {
var x;
var v;
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
- v = nanrangeBy( x.length, x, 0, accessor );
+ v = nanrangeBy( x.length, toAccessorArray(x), 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
x = new Array( 1 ); // sparse array
@@ -184,6 +301,22 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
t.end();
});
+tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (accessors)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = nanrangeBy( x.length, toAccessorArray(x), 0, accessor );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ x = new Array( 1 ); // sparse array
+ v = nanrangeBy( 1, toAccessorArray(x), 0, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function supports view offsets', function test( t ) {
var x0;
var x1;
@@ -213,6 +346,35 @@ tape( 'the function supports view offsets', function test( t ) {
t.end();
});
+tape( 'the function supports view offsets (accessors)', function test( t ) {
+ var x0;
+ var x1;
+ var N;
+ var v;
+
+ x0 = new Float64Array([
+ 2.0,
+ 1.0, // 0
+ 2.0,
+ -2.0, // 1
+ -2.0,
+ 2.0, // 2
+ 3.0,
+ 4.0, // 3
+ 6.0,
+ NaN, // 4
+ NaN
+ ]);
+
+ x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
+ N = floor(x1.length / 2);
+
+ v = nanrangeBy( N, toAccessorArray(x1), 2, accessor );
+ t.strictEqual( v, 12.0, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function supports providing a callback execution context', function test( t ) {
var ctx;
var x;
@@ -231,3 +393,22 @@ tape( 'the function supports providing a callback execution context', function t
return v * 2.0;
}
});
+
+tape( 'the function supports providing a callback execution context (accessors)', function test( t ) {
+ var ctx;
+ var x;
+
+ x = [ 1.0, 2.0, 3.0, NaN, 4.0, 5.0 ];
+ ctx = {
+ 'count': 0
+ };
+ nanrangeBy( x.length, toAccessorArray(x), 1, accessor, ctx );
+
+ t.strictEqual( ctx.count, x.length, 'returns expected value' );
+ t.end();
+
+ function accessor( v ) {
+ this.count += 1; // eslint-disable-line no-invalid-this
+ return v * 2.0;
+ }
+});
From 858f1ea37d3f39e67d860142096baeaa9685baa0 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:30:01 +0530
Subject: [PATCH 06/36] Update test.ndarray.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../base/nanrange-by/test/test.ndarray.js | 174 ++++++++++++++++++
1 file changed, 174 insertions(+)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
index 33f6c629025d..1293ff90cef2 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
@@ -22,6 +22,7 @@
var tape = require( 'tape' );
var floor = require( '@stdlib/math/base/special/floor' );
+var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
var nanrangeBy = require( './../lib/ndarray.js' );
@@ -86,6 +87,42 @@ tape( 'the function calculates the range of a strided array via a callback funct
t.end();
});
+tape( 'the function calculates the range of a strided array via a callback function, ignoring NaN values (accessors)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, NaN, 3.0 ];
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ t.strictEqual( v, 18.0, 'returns expected value' );
+
+ x = [ -4.0, NaN, -5.0 ];
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ t.strictEqual( v, 2.0, 'returns expected value' );
+
+ x = [ -0.0, 0.0, NaN, -0.0 ];
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );
+
+ x = [ NaN ];
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ x = [ NaN, NaN ];
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ x = new Array( 5 ); // sparse array
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ x = new Array( 5 ); // sparse array
+ x[ 2 ] = 1.0;
+ v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) {
var x;
var v;
@@ -101,6 +138,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
t.end();
});
+tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessor)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = nanrangeBy( 0, toAccessorArray(x), 1, 0, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ v = nanrangeBy( -1, toAccessorArray(x), 1, 0, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) {
var x;
var v;
@@ -117,6 +169,22 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun
t.end();
});
+tape( 'if provided an `N` parameter equal to `1`, the function returns `0` (accessor)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = nanrangeBy( 1, toAccessorArray(x), 1, 0, accessor );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ x = new Array( 1 ); // sparse array
+ v = nanrangeBy( 1, toAccessorArray(x), 1, 0, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function supports a `stride` parameter', function test( t ) {
var N;
var x;
@@ -142,6 +210,31 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
t.end();
});
+tape( 'the function supports a `stride` parameter (accessors)', function test( t ) {
+ var N;
+ var x;
+ var v;
+
+ x = [
+ 1.0, // 0
+ 2.0,
+ 2.0, // 1
+ -7.0,
+ -2.0, // 2
+ 3.0,
+ 4.0, // 3
+ 2.0,
+ NaN, // 4
+ NaN
+ ];
+
+ N = floor( x.length / 2 );
+ v = nanrangeBy( N, toAccessorArray(x), 2, 0, accessor );
+
+ t.strictEqual( v, 12.0, 'returns expected value' );
+ t.end();
+});
+
tape( 'the function supports a negative `stride` parameter', function test( t ) {
var N;
var x;
@@ -167,6 +260,31 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
t.end();
});
+tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) {
+ var N;
+ var x;
+ var v;
+
+ x = [
+ NaN, // 4
+ NaN,
+ 1.0, // 3
+ 2.0,
+ 2.0, // 2
+ -7.0,
+ -2.0, // 1
+ 3.0,
+ 4.0, // 0
+ 2.0
+ ];
+
+ N = floor( x.length / 2 );
+ v = nanrangeBy( N, toAccessorArray(x), -2, 8, accessor );
+
+ t.strictEqual( v, 12.0, 'returns expected value' );
+ t.end();
+});
+
tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', function test( t ) {
var x;
var v;
@@ -183,6 +301,22 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
t.end();
});
+tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (accessors)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = nanrangeBy( x.length, toAccessorArray(x), 0, 0, accessor );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ x = new Array( 1 ); // sparse array
+ v = nanrangeBy( 1, toAccessorArray(x), 0, 0, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function supports an offset parameter', function test( t ) {
var x;
var v;
@@ -204,6 +338,27 @@ tape( 'the function supports an offset parameter', function test( t ) {
t.end();
});
+tape( 'the function supports an offset parameter (accessors)', function test( t ) {
+ var x;
+ var v;
+
+ x = [
+ 1.0,
+ -2.0, // 0
+ 3.0,
+ 4.0, // 1
+ 5.0,
+ -6.0, // 2
+ NaN,
+ NaN // 3
+ ];
+
+ v = nanrangeBy( 4, toAccessorArray(x), 2, 1, accessor );
+ t.strictEqual( v, 20.0, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function supports providing a callback execution context', function test( t ) {
var ctx;
var x;
@@ -222,3 +377,22 @@ tape( 'the function supports providing a callback execution context', function t
return v * 2.0;
}
});
+
+tape( 'the function supports providing a callback execution context (accessors)', function test( t ) {
+ var ctx;
+ var x;
+
+ x = [ 1.0, 2.0, 3.0, NaN, 4.0, 5.0 ];
+ ctx = {
+ 'count': 0
+ };
+ nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor, ctx );
+
+ t.strictEqual( ctx.count, x.length, 'returns expected value' );
+ t.end();
+
+ function accessor( v ) {
+ this.count += 1; // eslint-disable-line no-invalid-this
+ return v * 2.0;
+ }
+});
From d5f8c588a41796a6d7f84a6469cf2b567d69484f Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:30:38 +0530
Subject: [PATCH 07/36] Update README.md
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../@stdlib/stats/base/nanrange-by/README.md | 35 ++++++++-----------
1 file changed, 15 insertions(+), 20 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
index 7b0aa8cbc599..a1ecb1f48b6d 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
@@ -2,7 +2,7 @@
@license Apache-2.0
-Copyright (c) 2020 The Stdlib Authors.
+Copyright (c) 2025 The Stdlib Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ The [**range**][range] is defined as the difference between the maximum and mini
var nanrangeBy = require( '@stdlib/stats/base/nanrange-by' );
```
-#### nanrangeBy( N, x, stride, clbk\[, thisArg] )
+#### nanrangeBy( N, x, strideX, clbk\[, thisArg] )
Calculates the [range][range] of strided array `x` via a callback function, ignoring `NaN` values.
@@ -57,7 +57,7 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions).
-- **stride**: index increment.
+- **strideX**: index increment.
- **clbk**: callback function.
- **thisArg**: execution context (_optional_).
@@ -65,7 +65,7 @@ The invoked callback is provided four arguments:
- **value**: array element.
- **aidx**: array index.
-- **sidx**: strided index (`offset + aidx*stride`).
+- **sidx**: strided index (`offsetX + aidx*strideX`).
- **array**: input array/collection.
To set the callback execution context, provide a `thisArg`.
@@ -89,7 +89,7 @@ var cnt = context.count;
// returns 10
```
-The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element
+The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element
```javascript
var floor = require( '@stdlib/math/base/special/floor' );
@@ -127,7 +127,7 @@ var v = nanrangeBy( N, x1, 2, accessor );
// returns 8.0
```
-#### nanrangeBy.ndarray( N, x, stride, offset, clbk\[, thisArg] )
+#### nanrangeBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] )
Calculates the [range][range] of strided array `x` via a callback function, ignoring `NaN` values and using alternative indexing semantics.
@@ -144,9 +144,9 @@ var v = nanrangeBy.ndarray( x.length, x, 1, 0, accessor );
The function has the following additional parameters:
-- **offset**: starting index.
+- **offsetX**: starting index.
-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`
+While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offsetX` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x`
```javascript
function accessor( v ) {
@@ -185,22 +185,23 @@ var v = nanrangeBy.ndarray( 3, x, 1, x.length-3, accessor );
```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
var nanrangeBy = require( '@stdlib/stats/base/nanrange-by' );
-function fill() {
- if ( randu() < 0.2 ) {
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
return NaN;
}
- return discreteUniform( -50, 50 );
+ return uniform( -50.0, 50.0 );
}
function accessor( v ) {
return v * 2.0;
}
-var x = filledarrayBy( 10, 'float64', fill );
+var x = filledarrayBy( 10, 'float64', rand );
console.log( x );
var v = nanrangeBy( x.length, x, 1, accessor );
@@ -235,23 +236,17 @@ console.log( v );
[range]: https://en.wikipedia.org/wiki/Range_%28statistics%29
-
[mdn-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
-
+[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
[@stdlib/stats/base/dnanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dnanrange
-
[@stdlib/stats/base/nanmax-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanmax-by
-
[@stdlib/stats/base/nanmin-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanmin-by
-
[@stdlib/stats/base/nanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanrange
-
[@stdlib/stats/base/range-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/range-by
-
[@stdlib/stats/base/snanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/snanrange
From d0d1f6a3f9353fcccffc17d74dc47828da3458b2 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:31:11 +0530
Subject: [PATCH 08/36] Update index.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../stats/base/nanrange-by/examples/index.js | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js
index 8aaaf469c7a4..83b9f6546aed 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,22 +19,23 @@
'use strict';
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
var nanrangeBy = require( './../lib' );
-function fill() {
- if ( randu() < 0.2 ) {
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
return NaN;
}
- return discreteUniform( -50, 50 );
+ return uniform( -50.0, 50.0 );
}
function accessor( v ) {
return v * 2.0;
}
-var x = filledarrayBy( 10, 'float64', fill );
+var x = filledarrayBy( 10, 'float64', rand );
console.log( x );
var v = nanrangeBy( x.length, x, 1, accessor );
From 70b06be129f6e3405542ef1cca3b6e372565df82 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:31:47 +0530
Subject: [PATCH 09/36] Update index.d.ts
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../base/nanrange-by/docs/types/index.d.ts | 28 +++++++++++--------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts
index 502636524eb1..01ff85a8ea1b 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,11 @@
///
-import { Collection } from '@stdlib/types/array';
+import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';
+/**
+* Input array.
+*/
+type InputArray = NumericArray | Collection | AccessorArrayLike;
/**
* Returns an accessed value.
@@ -61,7 +65,7 @@ type Ternary = ( this: U, value: T, aidx: number, sidx: number ) => number
*
* @param value - array element
* @param aidx - array index
-* @param sidx - strided index (offset + aidx*stride)
+* @param sidx - strided index (offsetX + aidx*strideX)
* @param array - input array
* @returns accessed value
*/
@@ -72,7 +76,7 @@ type Quaternary = ( this: U, value: T, aidx: number, sidx: number, array:
*
* @param value - array element
* @param aidx - array index
-* @param sidx - strided index (offset + aidx*stride)
+* @param sidx - strided index (offsetX + aidx*strideX)
* @param array - input array
* @returns accessed value
*/
@@ -102,7 +106,7 @@ interface Routine {
*
* @param N - number of indexed elements
* @param x - input array
- * @param stride - stride length
+ * @param strideX - stride length
* @param clbk - callback
* @param thisArg - execution context
* @returns range
@@ -117,7 +121,7 @@ interface Routine {
* var v = nanrangeBy( x.length, x, 1, accessor );
* // returns 18.0
*/
- ( N: number, x: Collection, stride: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
+ ( N: number, x: InputArray, stride: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
/**
* Calculates the range of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics.
@@ -128,7 +132,7 @@ interface Routine {
*
* - `value`: array element
* - `aidx`: array index
- * - `sidx`: strided index (offset + aidx*stride)
+ * - `sidx`: strided index (offsetX + aidx*strideX)
* - `array`: input array
*
* - The callback function should return a numeric value.
@@ -139,8 +143,8 @@ interface Routine {
*
* @param N - number of indexed elements
* @param x - input array
- * @param stride - stride length
- * @param offset - starting index
+ * @param strideX - stride length
+ * @param offsetX - starting index
* @param clbk - callback
* @param thisArg - execution context
* @returns range
@@ -155,7 +159,7 @@ interface Routine {
* var v = nanrangeBy.ndarray( x.length, x, 1, 0, accessor );
* // returns 18.0
*/
- ndarray( N: number, x: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
+ ndarray( N: number, x: InputArray, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
}
/**
@@ -167,7 +171,7 @@ interface Routine {
*
* - `value`: array element
* - `aidx`: array index
-* - `sidx`: strided index (offset + aidx*stride)
+* - `sidx`: strided index (offsetX + aidx*strideX)
* - `array`: input array
*
* - The callback function should return a numeric value.
@@ -178,7 +182,7 @@ interface Routine {
*
* @param N - number of indexed elements
* @param x - input array
-* @param stride - stride length
+* @param strideX - stride length
* @param clbk - callback
* @param thisArg - execution context
* @returns range
From 57ab24ab623191eea292d6bbb0a65b86cc72c7a6 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:32:21 +0530
Subject: [PATCH 10/36] Update test.ts
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../@stdlib/stats/base/nanrange-by/docs/types/test.ts | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts
index 076af8773ea2..d411119995c2 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
*/
import nanrangeBy = require( './index' );
+import AccessorArray = require( '@stdlib/array/base/accessor' );
const accessor = (): number => {
return 5.0;
@@ -29,8 +30,8 @@ const accessor = (): number => {
{
const x = new Float64Array( 10 );
- nanrangeBy( x.length, x, 1, accessor ); // $ExpectType number
- nanrangeBy( x.length, x, 1, accessor, {} ); // $ExpectType number
+ nanrangeBy( x.length, new AccessorArray( x ), 1, accessor ); // $ExpectType number
+ nanrangeBy( x.length, new AccessorArray( x ), 1, accessor, {} ); // $ExpectType number
}
// The compiler throws an error if the function is provided a first argument which is not a number...
@@ -101,8 +102,8 @@ const accessor = (): number => {
{
const x = new Float64Array( 10 );
- nanrangeBy.ndarray( x.length, x, 1, 0, accessor ); // $ExpectType number
- nanrangeBy.ndarray( x.length, x, 1, 0, accessor, {} ); // $ExpectType number
+ nanrangeBy.ndarray( x.length, new AccessorArray( x ), 1, 0, accessor ); // $ExpectType number
+ nanrangeBy.ndarray( x.length, new AccessorArray( x ), 1, 0, accessor, {} ); // $ExpectType number
}
// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
From a29bea7b0985b53d89acc04a31b2ad99cca377a5 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:33:51 +0530
Subject: [PATCH 11/36] Update repl.txt
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../stats/base/nanrange-by/docs/repl.txt | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt
index 306a3a977dd2..686c28dd1df3 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt
@@ -1,9 +1,9 @@
-{{alias}}( N, x, stride, clbk[, thisArg] )
+{{alias}}( N, x, strideX, clbk[, thisArg] )
Calculates the range of a strided array via a callback function, ignoring
`NaN` values.
- The `N` and `stride` parameters determine which elements in `x` are accessed
+ The `N` and `strideX` parameters determine which elements in `x` are accessed
at runtime.
Indexing is relative to the first index. To introduce an offset, use typed
@@ -15,7 +15,7 @@
- value: array element.
- aidx: array index.
- - sidx: strided index (offset + aidx*stride).
+ - sidx: strided index (offsetX + aidx*strideX).
- array: the input array.
The callback function should return a numeric value.
@@ -34,7 +34,7 @@
Input array/collection. If provided an object, the object must be array-
like (excluding strings and functions).
- stride: integer
+ strideX: integer
Index increment for `x`.
clbk: Function
@@ -56,7 +56,7 @@
> {{alias}}( x.length, x, 1, accessor )
18.0
- // Using `N` and `stride` parameters:
+ // Using `N` and `strideX` parameters:
> x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0, 1.0 ];
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}( N, x, 2, accessor )
@@ -69,12 +69,12 @@
> {{alias}}( N, x1, 2, accessor )
8.0
-{{alias}}.ndarray( N, x, stride, offset, clbk[, thisArg] )
+{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] )
Calculates the range of a strided array via a callback function, ignoring
`NaN` values and using alternative indexing semantics.
While typed array views mandate a view offset based on the underlying
- buffer, the `offset` parameter supports indexing semantics based on a
+ buffer, the `offsetX` parameter supports indexing semantics based on a
starting index.
Parameters
@@ -86,10 +86,10 @@
Input array/collection. If provided an object, the object must be array-
like (excluding strings and functions).
- stride: integer
+ strideX: integer
Index increment for `x`.
- offset: integer
+ offsetX: integer
Starting index of `x`.
clbk: Function
From 752c833c6b9901b42ebe70992d0495482bd7b442 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:34:59 +0530
Subject: [PATCH 12/36] Update benchmark.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../base/nanrange-by/benchmark/benchmark.js | 25 +++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js
index 497323944104..67e1e191cc08 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,9 @@
// MODULES //
var bench = require( '@stdlib/bench' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var pkg = require( './../package.json' ).name;
@@ -37,6 +39,13 @@ var nanrangeBy = require( './../lib/nanrange_by.js' );
* @param {number} value - array element
* @returns {number} accessed value
*/
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -50.0, 50.0 );
+}
+
function accessor( value ) {
return value * 2.0;
}
@@ -49,17 +58,7 @@ function accessor( value ) {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x;
- var i;
-
- x = [];
- for ( i = 0; i < len; i++ ) {
- if ( randu() < 0.2 ) {
- x.push( NaN );
- } else {
- x.push( ( randu()*20.0 ) - 10.0 );
- }
- }
+ var x = filledarrayBy( len, "float64", rand );
return benchmark;
function benchmark( b ) {
From d2f131195253c92b5a479ad91d990cce5dccdddb Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:35:29 +0530
Subject: [PATCH 13/36] Update benchmark.ndarray.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../benchmark/benchmark.ndarray.js | 25 +++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js
index 8b8c84d3bdb2..000aeac3035b 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,9 @@
// MODULES //
var bench = require( '@stdlib/bench' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var pkg = require( './../package.json' ).name;
@@ -37,6 +39,13 @@ var nanrangeBy = require( './../lib/ndarray.js' );
* @param {number} value - array element
* @returns {number} accessed value
*/
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -50.0, 50.0 );
+}
+
function accessor( value ) {
return value * 2.0;
}
@@ -49,17 +58,7 @@ function accessor( value ) {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x;
- var i;
-
- x = [];
- for ( i = 0; i < len; i++ ) {
- if ( randu() < 0.2 ) {
- x.push( NaN );
- } else {
- x.push( ( randu()*20.0 ) - 10.0 );
- }
- }
+ var x = filledarrayBy( len, "float64", rand );
return benchmark;
function benchmark( b ) {
From eb4442d14f21c710cab9e01c37c634bbe056f9de Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 00:44:49 +0530
Subject: [PATCH 14/36] Update README.md
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
lib/node_modules/@stdlib/stats/base/nanrange-by/README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
index a1ecb1f48b6d..404fc3a49570 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
@@ -56,8 +56,8 @@ var v = nanrangeBy( x.length, x, 1, accessor );
The function has the following parameters:
- **N**: number of indexed elements.
-- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions).
-- **strideX**: index increment.
+- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions).
+- **stride**: index increment
- **clbk**: callback function.
- **thisArg**: execution context (_optional_).
From ff18103587fff03e1fa8df249f4c41fb7084777c Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 20:27:36 +0530
Subject: [PATCH 15/36] Update README.md
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../@stdlib/stats/base/nanrange-by/README.md | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
index 404fc3a49570..8786c2b2b13c 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
@@ -57,7 +57,7 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions).
-- **stride**: index increment
+- **strideX**: index increment.
- **clbk**: callback function.
- **thisArg**: execution context (_optional_).
@@ -171,7 +171,7 @@ var v = nanrangeBy.ndarray( 3, x, 1, x.length-3, accessor );
- A provided callback function should return a numeric value.
- If a provided callback function returns `NaN`, the value is ignored.
- If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is ignored.
-- When possible, prefer using [`dnanrange`][@stdlib/stats/base/dnanrange], [`snanrange`][@stdlib/stats/base/snanrange], and/or [`nanrange`][@stdlib/stats/base/nanrange], as, depending on the environment, these interfaces are likely to be significantly more performant.
+- 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.
@@ -220,12 +220,12 @@ console.log( v );
## See Also
-- [`@stdlib/stats/base/dnanrange`][@stdlib/stats/base/dnanrange]: calculate the range of a double-precision floating-point strided array, ignoring NaN values.
+- [`@stdlib/stats/strided/dnanrange`][@stdlib/stats/strided/dnanrange]: calculate the range of a double-precision floating-point strided array, ignoring NaN values.
- [`@stdlib/stats/base/nanmax-by`][@stdlib/stats/base/nanmax-by]: calculate the maximum value of a strided array via a callback function, ignoring NaN values.
- [`@stdlib/stats/base/nanmin-by`][@stdlib/stats/base/nanmin-by]: calculate the minimum value of a strided array via a callback function, ignoring NaN values.
- [`@stdlib/stats/base/nanrange`][@stdlib/stats/base/nanrange]: calculate the range of a strided array, ignoring NaN values.
- [`@stdlib/stats/base/range-by`][@stdlib/stats/base/range-by]: calculate the range of a strided array via a callback function.
-- [`@stdlib/stats/base/snanrange`][@stdlib/stats/base/snanrange]: calculate the range of a single-precision floating-point strided array, ignoring NaN values.
+- [`@stdlib/stats/strided/snanrange`][@stdlib/stats/strided/snanrange]: calculate the range of a single-precision floating-point strided array, ignoring NaN values.
@@ -236,18 +236,24 @@ console.log( v );
[range]: https://en.wikipedia.org/wiki/Range_%28statistics%29
+
[mdn-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
-[@stdlib/stats/base/dnanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dnanrange
+[@stdlib/stats/strided/dnanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/dnanrange
+
[@stdlib/stats/base/nanmax-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanmax-by
+
[@stdlib/stats/base/nanmin-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanmin-by
+
[@stdlib/stats/base/nanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanrange
+
[@stdlib/stats/base/range-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/range-by
-[@stdlib/stats/base/snanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/snanrange
+
+[@stdlib/stats/strided/snanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/snanrange
From 530df0a192fb42be6e911118b26404443e9203d0 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 20:46:31 +0530
Subject: [PATCH 16/36] Update README.md
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
lib/node_modules/@stdlib/stats/base/nanrange-by/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
index 8786c2b2b13c..52aabc22c2b2 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
@@ -57,7 +57,7 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions).
-- **strideX**: index increment.
+- **stride**: index increment.
- **clbk**: callback function.
- **thisArg**: execution context (_optional_).
From cdcf3f2c5b5428ce6650d833da68a48216453dd7 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 20:52:22 +0530
Subject: [PATCH 17/36] Update README.md
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
lib/node_modules/@stdlib/stats/base/nanrange-by/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
index 52aabc22c2b2..8786c2b2b13c 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
@@ -57,7 +57,7 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions).
-- **stride**: index increment.
+- **strideX**: index increment.
- **clbk**: callback function.
- **thisArg**: execution context (_optional_).
From 0bac44646e0f14d765a615e19a0cb048cef22a9f Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 20:55:22 +0530
Subject: [PATCH 18/36] Update README.md
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
lib/node_modules/@stdlib/stats/base/nanrange-by/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
index 8786c2b2b13c..52aabc22c2b2 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
@@ -57,7 +57,7 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions).
-- **strideX**: index increment.
+- **stride**: index increment.
- **clbk**: callback function.
- **thisArg**: execution context (_optional_).
From b7b52a298d0b062c48df53f803b9af8e3618e543 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 20:58:15 +0530
Subject: [PATCH 19/36] Update accessors.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../@stdlib/stats/base/nanrange-by/lib/accessors.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
index 1b6eb6bd0443..0d623cebee47 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2025 The Stdlib Authors
+* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
From 8920c660644d0f16630d3bb2f002a2bcf51328d3 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 20:58:31 +0530
Subject: [PATCH 20/36] Update ndarray.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
index 2365cd790e67..4c783c59551f 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2025 The Stdlib Authors
+* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
From 9008678240f2b8d8896562b774ca004c89ceab87 Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 21:05:28 +0530
Subject: [PATCH 21/36] Update accessors.js
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
.../stats/base/nanrange-by/lib/accessors.js | 56 +++++++++----------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
index 0d623cebee47..7c60deb063a9 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2025 The Stdlib Authors.
+* Copyright (c) 2025 The Stdlib Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,8 +29,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
*
* @param {PositiveInteger} N - number of indexed elements
* @param {Collection} x - input array/collection
-* @param {integer} stride - index increment
-* @param {NonNegativeInteger} offset - starting index
+* @param {integer} strideX - index increment
+* @param {NonNegativeInteger} offsetX - starting index
* @param {Callback} clbk - callback
* @param {*} [thisArg] - execution context
* @returns {number} range
@@ -63,38 +63,38 @@ function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
return NaN;
}
if ( N === 1 || strideX === 0 ) {
- v = clbk.call( thisArg, get( xbuf, 0 ), 0, 0, x );
- if ( v === void 0 || isnan( v ) ) {
- return NaN;
- }
- return 0.0;
+ v = clbk.call( thisArg, get( xbuf, 0 ), 0, 0, x );
+ if ( v === void 0 || isnan( v ) ) {
+ return NaN;
+ }
+ return 0.0;
}
ix = offsetX;
for ( i = 0; i < N; i++ ) {
- min = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
- if ( min === min && min !== void 0 ) {
- break;
- }
- ix += strideX;
+ min = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
+ if ( min === min && min !== void 0 ) {
+ break;
+ }
+ ix += strideX;
}
- if ( i === N ) {
- return NaN;
+ if ( i === N ) {
+ return NaN;
}
max = min;
i += 1;
- for ( i; i < N; i++ ) {
- ix += strideX;
- v = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
- if ( v === void 0 || isnan( v ) ) {
- continue;
- }
- if ( v < min ) {
- min = v;
- } else if ( v > max ) {
- max = v;
- }
- }
- return max - min;
+ for ( i; i < N; i++ ) {
+ ix += strideX;
+ v = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
+ if ( v === void 0 || isnan( v ) ) {
+ continue;
+ }
+ if ( v < min ) {
+ min = v;
+ }else if ( v > max ) {
+ max = v;
+ }
+ }
+ return max - min;
}
From 55a4cf247d52119832e868193d063615409ae61c Mon Sep 17 00:00:00 2001
From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
Date: Sun, 30 Mar 2025 23:46:00 +0530
Subject: [PATCH 22/36] Update README.md
Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
---
lib/node_modules/@stdlib/stats/base/nanrange-by/README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
index 52aabc22c2b2..206e2321f94c 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
@@ -168,6 +168,7 @@ var v = nanrangeBy.ndarray( 3, x, 1, x.length-3, accessor );
## Notes
- If `N <= 0`, both functions return `NaN`.
+- [@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
- A provided callback function should return a numeric value.
- If a provided callback function returns `NaN`, the value is ignored.
- If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is ignored.
@@ -238,7 +239,7 @@ console.log( v );
[range]: https://en.wikipedia.org/wiki/Range_%28statistics%29
[mdn-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
-[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
+
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
From 1c53e34e3c20fad37f3fcd521a3f03415d9c5b2e Mon Sep 17 00:00:00 2001
From: gururaj1512
Date: Sat, 5 Jul 2025 09:02:29 +0000
Subject: [PATCH 23/36] fix: readme file
---
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
---
---
.../@stdlib/stats/base/nanrange-by/README.md | 30 ++++++++-----------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
index f38b5849a68c..cb63285bcc88 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/README.md
@@ -2,7 +2,7 @@
@license Apache-2.0
-Copyright (c) 2025 The Stdlib Authors.
+Copyright (c) 2020 The Stdlib Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ var nanrangeBy = require( '@stdlib/stats/base/nanrange-by' );
#### nanrangeBy( N, x, strideX, clbk\[, thisArg] )
-Calculates the [range][range] of strided array `x` via a callback function, ignoring `NaN` values.
+Computes the [range][range] of a strided array via a callback function, ignoring `NaN` values.
```javascript
function accessor( v ) {
@@ -57,7 +57,7 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions).
-- **stride**: index increment.
+- **strideX**: stride length.
- **clbk**: callback function.
- **thisArg**: execution context (_optional_).
@@ -65,7 +65,7 @@ The invoked callback is provided four arguments:
- **value**: array element.
- **aidx**: array index.
-- **sidx**: strided index (`offsetX + aidx*strideX`).
+- **sidx**: strided index (`offset + aidx*stride`).
- **array**: input array/collection.
To set the callback execution context, provide a `thisArg`.
@@ -89,19 +89,16 @@ var cnt = context.count;
// returns 10
```
-The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element
+The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element
```javascript
-var floor = require( '@stdlib/math/base/special/floor' );
-
function accessor( v ) {
return v * 2.0;
}
var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0, NaN, NaN ];
-var N = floor( x.length / 2 );
-var v = nanrangeBy( N, x, 2, accessor );
+var v = nanrangeBy( 5, x, 2, accessor );
// returns 12.0
```
@@ -109,7 +106,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [
```javascript
var Float64Array = require( '@stdlib/array/float64' );
-var floor = require( '@stdlib/math/base/special/floor' );
function accessor( v ) {
return v * 2.0;
@@ -120,16 +116,15 @@ var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
// Create an offset view...
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
-var N = floor( x0.length/2 );
// Access every other element...
-var v = nanrangeBy( N, x1, 2, accessor );
+var v = nanrangeBy( 3, x1, 2, accessor );
// returns 8.0
```
#### nanrangeBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] )
-Calculates the [range][range] of strided array `x` via a callback function, ignoring `NaN` values and using alternative indexing semantics.
+Computes the [range][range] of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics.
```javascript
function accessor( v ) {
@@ -146,7 +141,7 @@ The function has the following additional parameters:
- **offsetX**: starting index.
-While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offsetX` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x`
+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`
```javascript
function accessor( v ) {
@@ -168,10 +163,10 @@ var v = nanrangeBy.ndarray( 3, x, 1, x.length-3, accessor );
## Notes
- If `N <= 0`, both functions return `NaN`.
-- [@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
- A provided callback function should return a numeric value.
- If a provided callback function returns `NaN`, the value is ignored.
- If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is ignored.
+- 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]).
- 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.
@@ -185,14 +180,13 @@ var v = nanrangeBy.ndarray( 3, x, 1, x.length-3, accessor );
```javascript
-var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var uniform = require( '@stdlib/random/base/uniform' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
var bernoulli = require( '@stdlib/random/base/bernoulli' );
var nanrangeBy = require( '@stdlib/stats/base/nanrange-by' );
function rand() {
- if ( bernoulli( 0.8 ) < 1 ) {
+ if ( bernoulli( 0.8 ) < 0.2 ) {
return NaN;
}
return uniform( -50.0, 50.0 );
@@ -242,6 +236,8 @@ console.log( v );
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
+[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
+
[@stdlib/stats/strided/dnanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/dnanrange
From 92e7a5d9fe48957d80f123f1c662d0a6c0f7e23a Mon Sep 17 00:00:00 2001
From: gururaj1512
Date: Sat, 5 Jul 2025 09:07:53 +0000
Subject: [PATCH 24/36] fix: benchmarks
---
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: na
- 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: passed
- 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
---
---
.../base/nanrange-by/benchmark/benchmark.js | 20 ++++++++++++-------
.../benchmark/benchmark.ndarray.js | 18 +++++++++++------
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js
index 67e1e191cc08..3931e4e384cf 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2025 The Stdlib Authors.
+* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ var bernoulli = require( '@stdlib/random/base/bernoulli' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var pkg = require( './../package.json' ).name;
-var nanrangeBy = require( './../lib/nanrange_by.js' );
+var nanrangeBy = require( './../lib/main.js' );
// FUNCTIONS //
@@ -39,6 +39,16 @@ var nanrangeBy = require( './../lib/nanrange_by.js' );
* @param {number} value - array element
* @returns {number} accessed value
*/
+function accessor( value ) {
+ return value * 2.0;
+}
+
+/**
+* Returns a random number.
+*
+* @private
+* @returns {number} random number
+*/
function rand() {
if ( bernoulli( 0.8 ) < 1 ) {
return NaN;
@@ -46,10 +56,6 @@ function rand() {
return uniform( -50.0, 50.0 );
}
-function accessor( value ) {
- return value * 2.0;
-}
-
/**
* Create a benchmark function.
*
@@ -58,7 +64,7 @@ function accessor( value ) {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x = filledarrayBy( len, "float64", rand );
+ var x = filledarrayBy( len, 'generic', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js
index 000aeac3035b..cec2b32c4fa0 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2025 The Stdlib Authors.
+* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +39,16 @@ var nanrangeBy = require( './../lib/ndarray.js' );
* @param {number} value - array element
* @returns {number} accessed value
*/
+function accessor( value ) {
+ return value * 2.0;
+}
+
+/**
+* Returns a random number.
+*
+* @private
+* @returns {number} random number
+*/
function rand() {
if ( bernoulli( 0.8 ) < 1 ) {
return NaN;
@@ -46,10 +56,6 @@ function rand() {
return uniform( -50.0, 50.0 );
}
-function accessor( value ) {
- return value * 2.0;
-}
-
/**
* Create a benchmark function.
*
@@ -58,7 +64,7 @@ function accessor( value ) {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x = filledarrayBy( len, "float64", rand );
+ var x = filledarrayBy( len, 'generic', rand );
return benchmark;
function benchmark( b ) {
From 945f05fef5c55e1df9f0e073fb58fb1b2e149b25 Mon Sep 17 00:00:00 2001
From: gururaj1512
Date: Sat, 5 Jul 2025 09:13:29 +0000
Subject: [PATCH 25/36] fix: update repl
---
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: na
- 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
---
---
.../stats/base/nanrange-by/docs/repl.txt | 28 +++++++++----------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt
index 686c28dd1df3..3425fd2e6bcf 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt
@@ -1,10 +1,10 @@
{{alias}}( N, x, strideX, clbk[, thisArg] )
- Calculates the range of a strided array via a callback function, ignoring
+ Computes the range of a strided array via a callback function, ignoring
`NaN` values.
- The `N` and `strideX` parameters determine which elements in `x` are accessed
- at runtime.
+ The `N` and stride parameters determine which elements in the strided array
+ are accessed at runtime.
Indexing is relative to the first index. To introduce an offset, use typed
array views.
@@ -15,7 +15,7 @@
- value: array element.
- aidx: array index.
- - sidx: strided index (offsetX + aidx*strideX).
+ - sidx: strided index (offset + aidx*stride).
- array: the input array.
The callback function should return a numeric value.
@@ -35,7 +35,7 @@
like (excluding strings and functions).
strideX: integer
- Index increment for `x`.
+ Stride length.
clbk: Function
Callback function.
@@ -56,25 +56,24 @@
> {{alias}}( x.length, x, 1, accessor )
18.0
- // Using `N` and `strideX` parameters:
+ // Using `N` and stride parameters:
> x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0, 1.0 ];
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
- > {{alias}}( N, x, 2, accessor )
+ > {{alias}}( 4, x, 2, accessor )
14.0
// Using view offsets:
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
- > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
- > {{alias}}( N, x1, 2, accessor )
+ > {{alias}}( 3, x1, 2, accessor )
8.0
+
{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] )
Calculates the range of a strided array via a callback function, ignoring
`NaN` values and using alternative indexing semantics.
While typed array views mandate a view offset based on the underlying
- buffer, the `offsetX` parameter supports indexing semantics based on a
+ buffer, the offset parameter supports indexing semantics based on a
starting index.
Parameters
@@ -87,10 +86,10 @@
like (excluding strings and functions).
strideX: integer
- Index increment for `x`.
+ Stride length.
offsetX: integer
- Starting index of `x`.
+ Starting index.
clbk: Function
Callback function.
@@ -113,8 +112,7 @@
// Using an index offset:
> x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
- > {{alias}}.ndarray( N, x, 2, 1, accessor )
+ > {{alias}}.ndarray( 3, x, 2, 1, accessor )
8.0
See Also
From 08534e63daa65eac5f8cc1e15becd94016005266 Mon Sep 17 00:00:00 2001
From: gururaj1512
Date: Sat, 5 Jul 2025 09:18:34 +0000
Subject: [PATCH 26/36] fix: update type definitions for nanrangeBy
---
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: na
- 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: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
.../base/nanrange-by/docs/types/index.d.ts | 25 ++++++++++---------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts
index 01ff85a8ea1b..caa6d2312b59 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
-* Copyright (c) 2025 The Stdlib Authors.
+* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +20,12 @@
///
-import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';
+import { Collection, AccessorArrayLike } from '@stdlib/types/array';
+
/**
* Input array.
*/
-type InputArray = NumericArray | Collection | AccessorArrayLike;
+type InputArray = Collection | AccessorArrayLike;
/**
* Returns an accessed value.
@@ -65,7 +66,7 @@ type Ternary = ( this: U, value: T, aidx: number, sidx: number ) => number
*
* @param value - array element
* @param aidx - array index
-* @param sidx - strided index (offsetX + aidx*strideX)
+* @param sidx - strided index (offset + aidx*stride)
* @param array - input array
* @returns accessed value
*/
@@ -76,7 +77,7 @@ type Quaternary = ( this: U, value: T, aidx: number, sidx: number, array:
*
* @param value - array element
* @param aidx - array index
-* @param sidx - strided index (offsetX + aidx*strideX)
+* @param sidx - strided index (offset + aidx*stride)
* @param array - input array
* @returns accessed value
*/
@@ -87,7 +88,7 @@ type Callback = Nullary | Unary | Binary | Ternary |
*/
interface Routine {
/**
- * Calculates the range of a strided array via a callback function, ignoring `NaN` values.
+ * Computes the range of a strided array via a callback function, ignoring `NaN` values.
*
* ## Notes
*
@@ -121,10 +122,10 @@ interface Routine {
* var v = nanrangeBy( x.length, x, 1, accessor );
* // returns 18.0
*/
- ( N: number, x: InputArray, stride: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
+ ( N: number, x: InputArray, strideX: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
/**
- * Calculates the range of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics.
+ * Computes the range of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics.
*
* ## Notes
*
@@ -132,7 +133,7 @@ interface Routine {
*
* - `value`: array element
* - `aidx`: array index
- * - `sidx`: strided index (offsetX + aidx*strideX)
+ * - `sidx`: strided index (offset + aidx*stride)
* - `array`: input array
*
* - The callback function should return a numeric value.
@@ -159,11 +160,11 @@ interface Routine {
* var v = nanrangeBy.ndarray( x.length, x, 1, 0, accessor );
* // returns 18.0
*/
- ndarray( N: number, x: InputArray, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
+ ndarray( N: number, x: InputArray, strideX: number, offsetX: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
}
/**
-* Calculates the range of a strided array via a callback function, ignoring `NaN` values.
+* Computes the range of a strided array via a callback function, ignoring `NaN` values.
*
* ## Notes
*
@@ -171,7 +172,7 @@ interface Routine {
*
* - `value`: array element
* - `aidx`: array index
-* - `sidx`: strided index (offsetX + aidx*strideX)
+* - `sidx`: strided index (offset + aidx*stride)
* - `array`: input array
*
* - The callback function should return a numeric value.
From ba4b4528e1170dcba9a54d04e91dacae9819e8c0 Mon Sep 17 00:00:00 2001
From: gururaj1512
Date: Sat, 5 Jul 2025 09:26:24 +0000
Subject: [PATCH 27/36] fix: correct test.ts
---
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: na
- 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: passed
- task: lint_license_headers
status: passed
---
---
.../stats/base/nanrange-by/docs/types/test.ts | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts
index d411119995c2..309fa8677c85 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
-* Copyright (c) 2025 The Stdlib Authors.
+* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
* limitations under the License.
*/
-import nanrangeBy = require( './index' );
import AccessorArray = require( '@stdlib/array/base/accessor' );
+import nanrangeBy = require( './index' );
const accessor = (): number => {
return 5.0;
@@ -30,7 +30,10 @@ const accessor = (): number => {
{
const x = new Float64Array( 10 );
+ nanrangeBy( x.length, x, 1, accessor ); // $ExpectType number
nanrangeBy( x.length, new AccessorArray( x ), 1, accessor ); // $ExpectType number
+
+ nanrangeBy( x.length, x, 1, accessor, {} ); // $ExpectType number
nanrangeBy( x.length, new AccessorArray( x ), 1, accessor, {} ); // $ExpectType number
}
@@ -71,7 +74,7 @@ const accessor = (): number => {
nanrangeBy( x.length, x, undefined, accessor ); // $ExpectError
nanrangeBy( x.length, x, [], accessor ); // $ExpectError
nanrangeBy( x.length, x, {}, accessor ); // $ExpectError
- nanrangeBy( x.length, x, ( x: number, accessor ): number => x, accessor ); // $ExpectError
+ nanrangeBy( x.length, x, ( x: number ): number => x, accessor ); // $ExpectError
}
// The compiler throws an error if the function is provided a fourth argument which is not a function...
@@ -102,7 +105,10 @@ const accessor = (): number => {
{
const x = new Float64Array( 10 );
+ nanrangeBy.ndarray( x.length, x, 1, 0, accessor ); // $ExpectType number
nanrangeBy.ndarray( x.length, new AccessorArray( x ), 1, 0, accessor ); // $ExpectType number
+
+ nanrangeBy.ndarray( x.length, x, 1, 0, accessor, {} ); // $ExpectType number
nanrangeBy.ndarray( x.length, new AccessorArray( x ), 1, 0, accessor, {} ); // $ExpectType number
}
From 648f0e07b26e21d51b3a6b287d44f32017d7da96 Mon Sep 17 00:00:00 2001
From: gururaj1512
Date: Sat, 5 Jul 2025 09:28:24 +0000
Subject: [PATCH 28/36] fix: 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: na
- 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: passed
- 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
---
---
.../@stdlib/stats/base/nanrange-by/examples/index.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js
index 83b9f6546aed..6f2b6c34b546 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2025 The Stdlib Authors.
+* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,14 +18,13 @@
'use strict';
-var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var uniform = require( '@stdlib/random/base/uniform' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
var bernoulli = require( '@stdlib/random/base/bernoulli' );
var nanrangeBy = require( './../lib' );
function rand() {
- if ( bernoulli( 0.8 ) < 1 ) {
+ if ( bernoulli( 0.8 ) < 0.2 ) {
return NaN;
}
return uniform( -50.0, 50.0 );
From bfaefbd8c8b2398f4f41f08fc6696793325478ca Mon Sep 17 00:00:00 2001
From: gururaj1512
Date: Sat, 5 Jul 2025 09:41:40 +0000
Subject: [PATCH 29/36] fix: implementation
---
.../stats/base/nanrange-by/lib/accessors.js | 62 ++++++++++---------
.../stats/base/nanrange-by/lib/index.js | 9 ++-
.../stats/base/nanrange-by/lib/main.js | 27 +++++++-
.../stats/base/nanrange-by/lib/nanrange_by.js | 55 ----------------
.../stats/base/nanrange-by/lib/ndarray.js | 8 +--
5 files changed, 69 insertions(+), 92 deletions(-)
delete mode 100644 lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
index 7c60deb063a9..60155660bf7c 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2025 The Stdlib Authors
+* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,27 +22,33 @@
var isnan = require( '@stdlib/math/base/assert/is-nan' );
+
// MAIN //
/**
-* Calculates the range of a strided array via a callback function, ignoring `NaN` values.
+* Computes the range of a strided array via a callback function, ignoring `NaN` values.
*
* @param {PositiveInteger} N - number of indexed elements
-* @param {Collection} x - input array/collection
-* @param {integer} strideX - index increment
+* @param {Object} x - input array object
+* @param {Collection} x.data - input array data
+* @param {Array} x.accessors - array element accessors
+* @param {integer} strideX - stride length
* @param {NonNegativeInteger} offsetX - starting index
* @param {Callback} clbk - callback
* @param {*} [thisArg] - execution context
* @returns {number} range
*
* @example
-* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ];
+* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
+* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
+*
+* var x = toAccessorArray( [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ] );
*
* function accessor( v ) {
* return v * 2.0;
* }
*
-* var v = nanrangeBy( x.length, x, 1, 0, accessor );
+* var v = nanrangeBy( x.length, arraylike2object( x ), 1, 0, accessor );
* // returns 18.0
*/
function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
@@ -59,40 +65,38 @@ function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
// Cache a reference to the element accessor:
get = x.accessors[0];
- if ( N <= 0 ) {
- return NaN;
- }
+
if ( N === 1 || strideX === 0 ) {
- v = clbk.call( thisArg, get( xbuf, 0 ), 0, 0, x );
- if ( v === void 0 || isnan( v ) ) {
- return NaN;
- }
- return 0.0;
+ v = clbk.call( thisArg, get( xbuf, offsetX ), 0, offsetX, x );
+ if ( v === void 0 || isnan( v ) ) {
+ return NaN;
+ }
+ return 0.0;
}
ix = offsetX;
for ( i = 0; i < N; i++ ) {
min = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
- if ( min === min && min !== void 0 ) {
- break;
- }
- ix += strideX;
+ if ( min === min && min !== void 0 ) {
+ break;
+ }
+ ix += strideX;
}
if ( i === N ) {
- return NaN;
+ return NaN;
}
max = min;
i += 1;
for ( i; i < N; i++ ) {
- ix += strideX;
- v = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
- if ( v === void 0 || isnan( v ) ) {
- continue;
- }
- if ( v < min ) {
- min = v;
- }else if ( v > max ) {
- max = v;
- }
+ ix += strideX;
+ v = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
+ if ( v === void 0 || isnan( v ) ) {
+ continue;
+ }
+ if ( v < min ) {
+ min = v;
+ } else if ( v > max ) {
+ max = v;
+ }
}
return max - min;
}
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js
index dfc81b840c2f..3ae440117e2e 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js
@@ -19,7 +19,7 @@
'use strict';
/**
-* Calculate the range of a strided array via a callback function and ignoring `NaN` values.
+* Compute the range of a strided array via a callback function and ignoring `NaN` values.
*
* @module @stdlib/stats/base/nanrange-by
*
@@ -50,7 +50,14 @@
// MODULES //
+var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
var main = require( './main.js' );
+var ndarray = require( './ndarray.js' );
+
+
+// MAIN //
+
+setReadOnly( main, 'ndarray', ndarray );
// EXPORTS //
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js
index 806353376607..522039ddf072 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js
@@ -20,14 +20,35 @@
// MODULES //
-var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var nanrangeBy = require( './nanrange_by.js' );
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
var ndarray = require( './ndarray.js' );
// MAIN //
-setReadOnly( nanrangeBy, 'ndarray', ndarray );
+/**
+* Computes the range of a strided array via a callback function, ignoring `NaN` values.
+*
+* @param {PositiveInteger} N - number of indexed elements
+* @param {Collection} x - input array
+* @param {integer} strideX - index increment
+* @param {Callback} clbk - callback
+* @param {*} [thisArg] - execution context
+* @returns {number} range
+*
+* @example
+* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ];
+*
+* function accessor( v ) {
+* return v * 2.0;
+* }
+*
+* var v = nanrangeBy( x.length, x, 1, accessor );
+* // returns 18.0
+*/
+function nanrangeBy( N, x, strideX, clbk, thisArg ) {
+ return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg);
+}
// EXPORTS //
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js
deleted file mode 100644
index 1aec8c0ebcae..000000000000
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
-* @license Apache-2.0
-*
-* Copyright (c) 2025 The Stdlib Authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-'use strict';
-
-// MODULES //
-
-var stride2offset = require( '@stdlib/strided/base/stride2offset' );
-var ndarray = require( './ndarray.js' );
-
-// MAIN //
-
-/**
-* Calculates the range of a strided array via a callback function, ignoring `NaN` values.
-*
-* @param {PositiveInteger} N - number of indexed elements
-* @param {Collection} x - input array/collection
-* @param {integer} strideX - index increment
-* @param {Callback} clbk - callback
-* @param {*} [thisArg] - execution context
-* @returns {number} range
-*
-* @example
-* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ];
-*
-* function accessor( v ) {
-* return v * 2.0;
-* }
-*
-* var v = nanrangeBy( x.length, x, 1, accessor );
-* // returns 18.0
-*/
-function nanrangeBy( N, x, strideX, clbk, thisArg ) {
- return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk , thisArg);
-}
-
-
-// EXPORTS //
-
-module.exports = nanrangeBy;
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
index 4c783c59551f..1b2508200408 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2025 The Stdlib Authors.
+* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ var accessors = require( './accessors.js' );
// MAIN //
/**
-* Calculates the range of a strided array via a callback function, ignoring `NaN` values.
+* Computes the range of a strided array via a callback function, ignoring `NaN` values.
*
* @param {PositiveInteger} N - number of indexed elements
* @param {Collection} x - input array/collection
@@ -51,8 +51,8 @@ var accessors = require( './accessors.js' );
function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
var max;
var min;
- var o;
var ix;
+ var o;
var v;
var i;
@@ -64,7 +64,7 @@ function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
return accessors( N, o, strideX, offsetX, clbk, thisArg );
}
if ( N === 1 || strideX === 0 ) {
- v = clbk.call( thisArg, x[ 0 ], 0, 0, x );
+ v = clbk.call( thisArg, x[ offsetX ], 0, offsetX, x );
if ( v === void 0 || isnan( v ) ) {
return NaN;
}
From 2c55276f9f99e652d756b7b318c01d1f8e084dbd Mon Sep 17 00:00:00 2001
From: gururaj1512
Date: Sat, 5 Jul 2025 09:46:23 +0000
Subject: [PATCH 30/36] chore: minor cleanup
---
.../@stdlib/stats/base/nanrange-by/lib/accessors.js | 2 +-
.../@stdlib/stats/base/nanrange-by/lib/ndarray.js | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
index 60155660bf7c..f73162919848 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
index 1b2508200408..1d517958bcd8 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
@@ -31,8 +31,8 @@ var accessors = require( './accessors.js' );
* Computes the range of a strided array via a callback function, ignoring `NaN` values.
*
* @param {PositiveInteger} N - number of indexed elements
-* @param {Collection} x - input array/collection
-* @param {integer} strideX - index increment
+* @param {Collection} x - input array
+* @param {integer} strideX - stride length
* @param {NonNegativeInteger} offsetX - starting index
* @param {Callback} clbk - callback
* @param {*} [thisArg] - execution context
From 4b34ad3713b555060ab46dd961e8e5b36a8c2909 Mon Sep 17 00:00:00 2001
From: gururaj1512
Date: Sat, 5 Jul 2025 09:58:26 +0000
Subject: [PATCH 31/36] fix: test files
---
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: na
- 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: passed
- 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
---
---
.../{test.nanrange_by.js => test.main.js} | 74 ++++++++-----------
.../base/nanrange-by/test/test.ndarray.js | 63 +++++++---------
2 files changed, 58 insertions(+), 79 deletions(-)
rename lib/node_modules/@stdlib/stats/base/nanrange-by/test/{test.nanrange_by.js => test.main.js} (81%)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.main.js
similarity index 81%
rename from lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js
rename to lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.main.js
index 9d72025be10d..acafb79889a2 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.main.js
@@ -21,12 +21,11 @@
// MODULES //
var tape = require( 'tape' );
-var floor = require( '@stdlib/math/base/special/floor' );
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
var Float64Array = require( '@stdlib/array/float64' );
-var nanrangeBy = require( './../lib/nanrange_by.js' );
+var nanrangeBy = require( './../lib' );
// FUNCTIONS //
@@ -76,11 +75,11 @@ tape( 'the function calculates the range of a strided array via a callback funct
v = nanrangeBy( x.length, x, 1, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- x = new Array( 5 ); // sparse array
+ x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
v = nanrangeBy( x.length, x, 1, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- x = new Array( 5 ); // sparse array
+ x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
x[ 2 ] = 1.0;
v = nanrangeBy( x.length, x, 1, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
@@ -93,32 +92,32 @@ tape( 'the function calculates the range of a strided array via a callback funct
var v;
x = [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, NaN, 3.0 ];
- v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, accessor );
t.strictEqual( v, 18.0, 'returns expected value' );
x = [ -4.0, NaN, -5.0 ];
- v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, accessor );
t.strictEqual( v, 2.0, 'returns expected value' );
x = [ -0.0, 0.0, NaN, -0.0 ];
- v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, accessor );
t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );
x = [ NaN ];
- v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
x = [ NaN, NaN ];
- v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- x = new Array( 5 ); // sparse array
- v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- x = new Array( 5 ); // sparse array
+ x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
x[ 2 ] = 1.0;
- v = nanrangeBy( x.length, toAccessorArray(x), 1, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
t.end();
@@ -145,10 +144,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
- v = nanrangeBy( 0, toAccessorArray(x), 1, accessor );
+ v = nanrangeBy( 0, toAccessorArray( x ), 1, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- v = nanrangeBy( -1, toAccessorArray(x), 1, accessor );
+ v = nanrangeBy( -1, toAccessorArray( x ), 1, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
@@ -163,30 +162,30 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun
v = nanrangeBy( 1, x, 1, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
- x = new Array( 1 ); // sparse array
+ x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
v = nanrangeBy( 1, x, 1, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
});
+
tape( 'if provided an `N` parameter equal to `1`, the function returns `0` (accessors)', function test( t ) {
var x;
var v;
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
- v = nanrangeBy( 1, toAccessorArray(x), 1, accessor );
+ v = nanrangeBy( 1, toAccessorArray( x ), 1, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
- x = new Array( 1 ); // sparse array
- v = nanrangeBy( 1, toAccessorArray(x), 1, accessor );
+ x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
+ v = nanrangeBy( 1, toAccessorArray( x ), 1, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
});
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -203,15 +202,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
NaN
];
- N = floor( x.length / 2 );
- v = nanrangeBy( N, x, 2, accessor );
+ v = nanrangeBy( 5, x, 2, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
});
tape( 'the function supports a `stride` parameter (accessors)', function test( t ) {
- var N;
var x;
var v;
@@ -228,15 +225,13 @@ tape( 'the function supports a `stride` parameter (accessors)', function test( t
NaN
];
- N = floor( x.length / 2 );
- v = nanrangeBy( N, toAccessorArray(x), 2, accessor );
+ v = nanrangeBy( 5, toAccessorArray( x ), 2, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -253,15 +248,13 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
2.0
];
- N = floor( x.length / 2 );
- v = nanrangeBy( N, x, -2, accessor );
+ v = nanrangeBy( 5, x, -2, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) {
- var N;
var x;
var v;
@@ -278,8 +271,7 @@ tape( 'the function supports a negative `stride` parameter (accessors)', functio
2.0
];
- N = floor( x.length / 2 );
- v = nanrangeBy( N, toAccessorArray(x), -2, accessor );
+ v = nanrangeBy( 5, toAccessorArray( x ), -2, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
@@ -291,10 +283,10 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
- v = nanrangeBy( x.length, toAccessorArray(x), 0, accessor );
+ v = nanrangeBy( x.length, x, 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
- x = new Array( 1 ); // sparse array
+ x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
v = nanrangeBy( 1, x, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
@@ -307,11 +299,11 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
- v = nanrangeBy( x.length, toAccessorArray(x), 0, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
- x = new Array( 1 ); // sparse array
- v = nanrangeBy( 1, toAccessorArray(x), 0, accessor );
+ x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
+ v = nanrangeBy( 1, toAccessorArray( x ), 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
@@ -320,7 +312,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (
tape( 'the function supports view offsets', function test( t ) {
var x0;
var x1;
- var N;
var v;
x0 = new Float64Array([
@@ -338,9 +329,8 @@ tape( 'the function supports view offsets', function test( t ) {
]);
x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
- N = floor(x1.length / 2);
- v = nanrangeBy( N, x1, 2, accessor );
+ v = nanrangeBy( 5, x1, 2, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
@@ -349,7 +339,6 @@ tape( 'the function supports view offsets', function test( t ) {
tape( 'the function supports view offsets (accessors)', function test( t ) {
var x0;
var x1;
- var N;
var v;
x0 = new Float64Array([
@@ -367,9 +356,8 @@ tape( 'the function supports view offsets (accessors)', function test( t ) {
]);
x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
- N = floor(x1.length / 2);
- v = nanrangeBy( N, toAccessorArray(x1), 2, accessor );
+ v = nanrangeBy( 5, toAccessorArray( x1 ), 2, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
@@ -402,7 +390,7 @@ tape( 'the function supports providing a callback execution context (accessors)'
ctx = {
'count': 0
};
- nanrangeBy( x.length, toAccessorArray(x), 1, accessor, ctx );
+ nanrangeBy( x.length, toAccessorArray( x ), 1, accessor, ctx );
t.strictEqual( ctx.count, x.length, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
index 1293ff90cef2..3886e6e119fe 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
@@ -21,7 +21,6 @@
// MODULES //
var tape = require( 'tape' );
-var floor = require( '@stdlib/math/base/special/floor' );
var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
@@ -75,11 +74,11 @@ tape( 'the function calculates the range of a strided array via a callback funct
v = nanrangeBy( x.length, x, 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- x = new Array( 5 ); // sparse array
+ x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
v = nanrangeBy( x.length, x, 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- x = new Array( 5 ); // sparse array
+ x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
x[ 2 ] = 1.0;
v = nanrangeBy( x.length, x, 1, 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
@@ -92,32 +91,32 @@ tape( 'the function calculates the range of a strided array via a callback funct
var v;
x = [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, NaN, 3.0 ];
- v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
t.strictEqual( v, 18.0, 'returns expected value' );
x = [ -4.0, NaN, -5.0 ];
- v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
t.strictEqual( v, 2.0, 'returns expected value' );
x = [ -0.0, 0.0, NaN, -0.0 ];
- v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );
x = [ NaN ];
- v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
x = [ NaN, NaN ];
- v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- x = new Array( 5 ); // sparse array
- v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- x = new Array( 5 ); // sparse array
+ x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
x[ 2 ] = 1.0;
- v = nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
t.end();
@@ -144,10 +143,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
- v = nanrangeBy( 0, toAccessorArray(x), 1, 0, accessor );
+ v = nanrangeBy( 0, toAccessorArray( x ), 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- v = nanrangeBy( -1, toAccessorArray(x), 1, 0, accessor );
+ v = nanrangeBy( -1, toAccessorArray( x ), 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
@@ -162,7 +161,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun
v = nanrangeBy( 1, x, 1, 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
- x = new Array( 1 ); // sparse array
+ x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
v = nanrangeBy( 1, x, 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
@@ -175,18 +174,17 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0` (acce
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
- v = nanrangeBy( 1, toAccessorArray(x), 1, 0, accessor );
+ v = nanrangeBy( 1, toAccessorArray( x ), 1, 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
- x = new Array( 1 ); // sparse array
- v = nanrangeBy( 1, toAccessorArray(x), 1, 0, accessor );
+ x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
+ v = nanrangeBy( 1, toAccessorArray( x ), 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
});
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -203,15 +201,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
NaN
];
- N = floor( x.length / 2 );
- v = nanrangeBy( N, x, 2, 0, accessor );
+ v = nanrangeBy( 5, x, 2, 0, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
});
tape( 'the function supports a `stride` parameter (accessors)', function test( t ) {
- var N;
var x;
var v;
@@ -228,15 +224,13 @@ tape( 'the function supports a `stride` parameter (accessors)', function test( t
NaN
];
- N = floor( x.length / 2 );
- v = nanrangeBy( N, toAccessorArray(x), 2, 0, accessor );
+ v = nanrangeBy( 5, toAccessorArray( x ), 2, 0, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -253,15 +247,13 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
2.0
];
- N = floor( x.length / 2 );
- v = nanrangeBy( N, x, -2, 8, accessor );
+ v = nanrangeBy( 5, x, -2, 8, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) {
- var N;
var x;
var v;
@@ -278,8 +270,7 @@ tape( 'the function supports a negative `stride` parameter (accessors)', functio
2.0
];
- N = floor( x.length / 2 );
- v = nanrangeBy( N, toAccessorArray(x), -2, 8, accessor );
+ v = nanrangeBy( 5, toAccessorArray( x ), -2, 8, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
@@ -294,7 +285,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
v = nanrangeBy( x.length, x, 0, 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
- x = new Array( 1 ); // sparse array
+ x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
v = nanrangeBy( 1, x, 0, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
@@ -307,11 +298,11 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
- v = nanrangeBy( x.length, toAccessorArray(x), 0, 0, accessor );
+ v = nanrangeBy( x.length, toAccessorArray( x ), 0, 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
- x = new Array( 1 ); // sparse array
- v = nanrangeBy( 1, toAccessorArray(x), 0, 0, accessor );
+ x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
+ v = nanrangeBy( 1, toAccessorArray( x ), 0, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
@@ -353,7 +344,7 @@ tape( 'the function supports an offset parameter (accessors)', function test( t
NaN // 3
];
- v = nanrangeBy( 4, toAccessorArray(x), 2, 1, accessor );
+ v = nanrangeBy( 4, toAccessorArray( x ), 2, 1, accessor );
t.strictEqual( v, 20.0, 'returns expected value' );
t.end();
@@ -386,7 +377,7 @@ tape( 'the function supports providing a callback execution context (accessors)'
ctx = {
'count': 0
};
- nanrangeBy( x.length, toAccessorArray(x), 1, 0, accessor, ctx );
+ nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor, ctx );
t.strictEqual( ctx.count, x.length, 'returns expected value' );
t.end();
From 41df8791b445845135688a2ebd1dcc0f108d78cd Mon Sep 17 00:00:00 2001
From: Gururaj Gurram <143020143+gururaj1512@users.noreply.github.com>
Date: Sat, 5 Jul 2025 16:33:06 +0530
Subject: [PATCH 32/36] fix: ensure original input array is passed to callback
Signed-off-by: Gururaj Gurram <143020143+gururaj1512@users.noreply.github.com>
---
.../@stdlib/stats/base/nanrange-by/lib/accessors.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
index f73162919848..19a23086a216 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/accessors.js
@@ -67,7 +67,7 @@ function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
get = x.accessors[0];
if ( N === 1 || strideX === 0 ) {
- v = clbk.call( thisArg, get( xbuf, offsetX ), 0, offsetX, x );
+ v = clbk.call( thisArg, get( xbuf, offsetX ), 0, offsetX, xbuf );
if ( v === void 0 || isnan( v ) ) {
return NaN;
}
@@ -75,7 +75,7 @@ function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
}
ix = offsetX;
for ( i = 0; i < N; i++ ) {
- min = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
+ min = clbk.call( thisArg, get( xbuf, ix ), i, ix, xbuf );
if ( min === min && min !== void 0 ) {
break;
}
@@ -88,7 +88,7 @@ function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
i += 1;
for ( i; i < N; i++ ) {
ix += strideX;
- v = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
+ v = clbk.call( thisArg, get( xbuf, ix ), i, ix, xbuf );
if ( v === void 0 || isnan( v ) ) {
continue;
}
From 22f574425f5bfb852f1a17d6f8460101bd3d3b9a Mon Sep 17 00:00:00 2001
From: Athan
Date: Sat, 5 Jul 2025 14:10:58 -0700
Subject: [PATCH 33/36] style: fix missing space
Signed-off-by: Athan
---
lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js
index 522039ddf072..e25596b0f392 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js
@@ -47,7 +47,7 @@ var ndarray = require( './ndarray.js' );
* // returns 18.0
*/
function nanrangeBy( N, x, strideX, clbk, thisArg ) {
- return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg);
+ return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg );
}
From 504d4f38c2cc5407ebcc94d98f71ec1d5c2ae7e4 Mon Sep 17 00:00:00 2001
From: Athan
Date: Sat, 5 Jul 2025 14:11:52 -0700
Subject: [PATCH 34/36] test: update description
Signed-off-by: Athan
---
.../@stdlib/stats/base/nanrange-by/test/test.main.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.main.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.main.js
index acafb79889a2..46f0e5eb0d47 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.main.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.main.js
@@ -87,7 +87,7 @@ tape( 'the function calculates the range of a strided array via a callback funct
t.end();
});
-tape( 'the function calculates the range of a strided array via a callback function, ignoring NaN values (accessor)', function test( t ) {
+tape( 'the function calculates the range of a strided array via a callback function, ignoring NaN values (accessors)', function test( t ) {
var x;
var v;
From fb500291defdadae6b1493b414757b643698699f Mon Sep 17 00:00:00 2001
From: Athan
Date: Sat, 5 Jul 2025 14:12:51 -0700
Subject: [PATCH 35/36] test: update desc
Signed-off-by: Athan
---
.../@stdlib/stats/base/nanrange-by/test/test.ndarray.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
index 3886e6e119fe..70e7127b636f 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
@@ -137,7 +137,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
t.end();
});
-tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessor)', function test( t ) {
+tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
var x;
var v;
From 25fbf2d6c016bf6aad7192e5181652eae2d07745 Mon Sep 17 00:00:00 2001
From: Athan
Date: Sat, 5 Jul 2025 14:13:53 -0700
Subject: [PATCH 36/36] test: update desc
Signed-off-by: Athan
---
.../@stdlib/stats/base/nanrange-by/test/test.ndarray.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
index 70e7127b636f..e56dff487a70 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
@@ -168,7 +168,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun
t.end();
});
-tape( 'if provided an `N` parameter equal to `1`, the function returns `0` (accessor)', function test( t ) {
+tape( 'if provided an `N` parameter equal to `1`, the function returns `0` (accessors)', function test( t ) {
var x;
var v;