From c2ce045b4fef7a4e0ee9a1e48bd60752d21ff309 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Tue, 4 Mar 2025 11:30:29 +0530 Subject: [PATCH 01/20] refactor benchmark --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- .../@stdlib/stats/base/range/README.md | 36 ++++++++----------- .../stats/base/range/benchmark/benchmark.js | 10 ++---- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/README.md b/lib/node_modules/@stdlib/stats/base/range/README.md index 9134551ef621..42e21fd685e1 100644 --- a/lib/node_modules/@stdlib/stats/base/range/README.md +++ b/lib/node_modules/@stdlib/stats/base/range/README.md @@ -38,7 +38,7 @@ The [**range**][range] is defined as the difference between the maximum and mini var range = require( '@stdlib/stats/base/range' ); ``` -#### range( N, x, stride ) +#### range( N, x, strideX ) Computes the [range][range] of a strided array `x`. @@ -54,17 +54,15 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. -- **stride**: index increment for `x`. +- **strideX**: stride length for `x`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [range][range] of every other element in `x`, +The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [range][range] of every other element in `x`, ```javascript -var floor = require( '@stdlib/math/base/special/floor' ); var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ]; -var N = floor( x.length / 2 ); -var v = range( N, x, 2 ); +var v = range( 4, x, 2 ); // returns 6.0 ``` @@ -74,18 +72,15 @@ 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' ); var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = range( N, x1, 2 ); +var v = range( 4, x1, 2 ); // returns 6.0 ``` -#### range.ndarray( N, x, stride, offset ) +#### range.ndarray( N, x, strideX, offsetX ) Computes the [range][range] of a strided array using alternative indexing semantics. @@ -99,17 +94,15 @@ var v = range.ndarray( N, x, 1, 0 ); The function has the following additional parameters: -- **offset**: starting index for `x`. +- **offsetX**: starting index for `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 calculate the [range][range] for every other value in `x` starting from the second value +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 calculate the [range][range] for every other value in `x` starting from the second value ```javascript -var floor = require( '@stdlib/math/base/special/floor' ); var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; -var N = floor( x.length / 2 ); -var v = range.ndarray( N, x, 2, 1 ); +var v = range.ndarray( 4, x, 2, 1 ); // returns 6.0 ``` @@ -123,6 +116,7 @@ var v = range.ndarray( N, x, 2, 1 ); - If `N <= 0`, both functions return `NaN`. - Depending on the environment, the typed versions ([`drange`][@stdlib/stats/base/drange], [`srange`][@stdlib/stats/base/srange], etc.) are likely to be significantly more performant. +- 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]). @@ -137,16 +131,14 @@ var v = range.ndarray( N, x, 2, 1 ); ```javascript var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var linspace = require( '@stdlib/array/base/linspace' ); var range = require( '@stdlib/stats/base/range' ); var x; var i; -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); -} +x = linspace(-50, 50, 10); +x = x.map(round); console.log( x ); var v = range( x.length, x, 1 ); @@ -185,6 +177,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/base/drange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/drange diff --git a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js index 587a3a985234..f835a24754a6 100644 --- a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js @@ -21,8 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var linspace = require( '@stdlib/array/linspace/docs/types/index' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; var range = require( './../lib/range.js' ); @@ -38,13 +38,7 @@ var range = require( './../lib/range.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( ( randu()*20.0 ) - 10.0 ); - } + var x = linspace( 0.0, len, len ); return benchmark; function benchmark( b ) { From ccc1cd04258b6de5547646f4a0012a4854f7b576 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Tue, 4 Mar 2025 14:43:13 +0530 Subject: [PATCH 02/20] refactor --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- .../stats/base/range/benchmark/benchmark.js | 2 +- .../base/range/benchmark/benchmark.ndarray.js | 8 +- .../@stdlib/stats/base/range/docs/repl.txt | 27 ++-- .../stats/base/range/docs/types/index.d.ts | 16 +- .../stats/base/range/docs/types/test.ts | 3 + .../stats/base/range/examples/index.js | 12 +- .../@stdlib/stats/base/range/lib/accessors.js | 91 +++++++++++ .../@stdlib/stats/base/range/lib/ndarray.js | 75 ++++----- .../@stdlib/stats/base/range/lib/range.js | 43 +----- .../stats/base/range/test/test.ndarray.js | 142 ++++++++++++++++-- .../stats/base/range/test/test.range.js | 105 +++++++++++-- 11 files changed, 391 insertions(+), 133 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/range/lib/accessors.js diff --git a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js index f835a24754a6..df0bb51f350c 100644 --- a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js @@ -22,7 +22,7 @@ var bench = require( '@stdlib/bench' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var linspace = require( '@stdlib/array/linspace/docs/types/index' ); +var linspace = require( '@stdlib/array/base/linspace' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; var range = require( './../lib/range.js' ); diff --git a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js index 642f0d216ce7..af564a17d3eb 100644 --- a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var randu = require( '@stdlib/random/base/randu' ); +var linspace = require( '@stdlib/array/linspace/docs/types/index' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; @@ -39,12 +40,7 @@ var range = require( './../lib/ndarray.js' ); */ function createBenchmark( len ) { var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( ( randu()*20.0 ) - 10.0 ); - } + var x = linspace( 0.0, len, len ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index d93f8c9e76c6..2b1569979610 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -1,8 +1,8 @@ -{{alias}}( N, x, stride ) +{{alias}}( N, x, strideX ) Computes the range of a strided array. - The `N` and `stride` parameters determine which elements in `x` are accessed + 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 a typed @@ -18,8 +18,8 @@ x: Array|TypedArray Input array. - stride: integer - Index increment. + strideX: integer + Stride length. Returns ------- @@ -33,22 +33,20 @@ > {{alias}}( x.length, x, 1 ) 4.0 - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); > var stride = 2; - > {{alias}}( N, x, stride ) + > {{alias}}( 3, x, stride ) 4.0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.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 ); > stride = 2; - > {{alias}}( N, x1, stride ) + > {{alias}}( 3, x1, stride ) 4.0 -{{alias}}.ndarray( N, x, stride, offset ) +{{alias}}.ndarray( N, x, strideX, offsetX ) Computes the range of a strided array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying @@ -63,10 +61,10 @@ x: Array|TypedArray Input array. - stride: integer - Index increment. + strideX: integer + Stride length. - offset: integer + offsetX: integer Starting index. Returns @@ -83,8 +81,7 @@ // Using offset parameter: > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1 ) + > {{alias}}.ndarray( 3, x, 2, 1 ) 4.0 See Also diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/range/docs/types/index.d.ts index 1d1fa3af1f6e..56a7ddb9a9f7 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/range/docs/types/index.d.ts @@ -20,18 +20,20 @@ /// -import { NumericArray } from '@stdlib/types/array'; +import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; /** * Interface describing `range`. */ +type InputArray = NumericArray | Collection | AccessorArrayLike; + interface Routine { /** * Computes the range of a strided array. * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length + * @param strideX - stride length * @returns range * * @example @@ -40,15 +42,15 @@ interface Routine { * var v = range( x.length, x, 1 ); * // returns 4.0 */ - ( N: number, x: NumericArray, stride: number ): number; + ( N: number, x: InputArray, strideX: number ): number; /** * Computes the range of a strided array using alternative indexing semantics. * * @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 * @returns range * * @example @@ -57,7 +59,7 @@ interface Routine { * var v = range.ndarray( x.length, x, 1, 0 ); * // returns 4.0 */ - ndarray( N: number, x: NumericArray, stride: number, offset: number ): number; + ndarray( N: number, x: InputArray, strideX: number, offsetX: number ): number; } /** @@ -65,7 +67,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array -* @param stride - stride length +* @param strideX - stride length * @returns range * * @example diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/range/docs/types/test.ts index 5e28c339f10c..c76d915dec2b 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/range/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import AccessorArray = require( '@stdlib/array/base/accessor' ); import range = require( './index' ); @@ -26,6 +27,7 @@ import range = require( './index' ); const x = new Float64Array( 10 ); range( x.length, x, 1 ); // $ExpectType number + range( x.length, new AccessorArray( x ), 1 ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -85,6 +87,7 @@ import range = require( './index' ); const x = new Float64Array( 10 ); range.ndarray( x.length, x, 1, 0 ); // $ExpectType number + range.ndarray( x.length, new AccessorArray( x ), 1, 0 ); // $ExpectType number } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... diff --git a/lib/node_modules/@stdlib/stats/base/range/examples/index.js b/lib/node_modules/@stdlib/stats/base/range/examples/index.js index 2b2bd004c144..168401689aed 100644 --- a/lib/node_modules/@stdlib/stats/base/range/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/range/examples/index.js @@ -18,18 +18,10 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var linspace = require( '@stdlib/array/base/linspace' ); var range = require( './../lib' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); -} +var x = linspace(-50, 50, 10); console.log( x ); var v = range( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js new file mode 100644 index 000000000000..ba4a7c4cb949 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js @@ -0,0 +1,91 @@ +/** +* @license Apache-2.0 +* +* 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. +* 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' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); + +// MAIN // + +/** +* Computes the range of a strided array using the accessor protocol. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Object} x - input array-like object supporting the accessor protocol +* @param {Function} get - accessor function to retrieve array values +* @param {integer} stride - stride length +* @returns {number} range (max - min) +* +* @example +* function accessor( arr, idx ) { +* return arr.get( idx ); +* } +* +* var x = { +* data: [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ], +* get: function( i ) { return this.data[ i ]; } +* }; +* +* var v = range( 3, x, accessor, 2 ); +* // returns 4.0 +*/ +function range( N, x, get, stride ) { + var max; + var min; + var ix; + var v; + var i; + + if ( N <= 0 ) { + return NaN; + } + if ( N === 1 || stride === 0 ) { + v = get( x, 0 ); + if ( isnan( v ) ) { + return NaN; + } + return 0.0; + } + if ( stride < 0 ) { + ix = (1 - N) * stride; + } else { + ix = 0; + } + min = get( x, ix ); + max = min; + for ( i = 1; i < N; i++ ) { + ix += stride; + v = get( x, ix ); + if ( isnan( v ) ) { + return v; + } + if ( v < min ) { + min = v; + } else if ( v > max ) { + max = v; + } + } + return max - min; +} + +// EXPORTS // + +module.exports = range; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js index 93676dd8afbb..4e8e163bc6c0 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js @@ -21,7 +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 +31,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * * @param {PositiveInteger} N - number of indexed elements * @param {NumericArray} x - input array -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - strideX length +* @param {NonNegativeInteger} offsetX - starting index * @returns {number} range * * @example @@ -40,44 +41,44 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; * var N = floor( x.length / 2 ); * -* var v = range( N, x, 2, 1 ); +* var v = range( 4, x, 2, 1 ); * // returns 6.0 */ -function range( N, x, stride, offset ) { - var max; - var min; - var ix; - var v; - var i; +function range( N, x, strideX, offsetX ) { + var obj = arraylike2object( x ); // Convert input to object with `data` property + var data = obj.data; // Extract data directly - if ( N <= 0 ) { - return NaN; - } - if ( N === 1 || stride === 0 ) { - if ( isnan( x[ offset ] ) ) { - return NaN; - } - return 0.0; - } - ix = offset; - min = x[ ix ]; - max = min; - for ( i = 1; i < N; i++ ) { - ix += stride; - v = x[ ix ]; - if ( isnan( v ) ) { - return v; - } - if ( v < min ) { - min = v; - } else if ( v > max ) { - max = v; - } - } - return max - min; -} + var max; + var min; + var ix; + var v; + var i; + if ( N <= 0 ) { + return NaN; + } + if ( N === 1 || strideX === 0 ) { + v = data[offsetX]; // Direct access instead of using an accessor function + return isnan( v ) ? NaN : 0.0; + } + ix = offsetX; + min = data[ix]; // Direct access + max = min; + for ( i = 1; i < N; i++ ) { + ix += strideX; + v = data[ix]; // Direct access + if ( isnan( v ) ) { + return v; + } + if ( v < min ) { + min = v; + } else if ( v > max ) { + max = v; + } + } + return max - min; +} // EXPORTS // -module.exports = range; +module.exports = range; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/range.js b/lib/node_modules/@stdlib/stats/base/range/lib/range.js index 921dd5c8040a..75af008ffba7 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/range.js +++ b/lib/node_modules/@stdlib/stats/base/range/lib/range.js @@ -21,7 +21,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 +31,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * * @param {PositiveInteger} N - number of indexed elements * @param {NumericArray} x - input array -* @param {integer} stride - stride length +* @param {integer} strideX - strideX length * @returns {number} range * * @example @@ -40,42 +41,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * var v = range( N, x, 1 ); * // returns 4.0 */ -function range( N, x, stride ) { - var max; - var min; - var ix; - var v; - var i; - - if ( N <= 0 ) { - return NaN; - } - if ( N === 1 || stride === 0 ) { - if ( isnan( x[ 0 ] ) ) { - return NaN; - } - return 0.0; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - min = x[ ix ]; - max = min; - for ( i = 1; i < N; i++ ) { - ix += stride; - v = x[ ix ]; - if ( isnan( v ) ) { - return v; - } - if ( v < min ) { - min = v; - } else if ( v > max ) { - max = v; - } - } - return max - min; +function range( N, x, strideX ) { + return ndarray( N, x, strideX, stride2offset( N, strideX ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js index 867c625caf5f..be0f499471fd 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js @@ -21,10 +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 range = require( './../lib/ndarray.js' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); // TESTS // @@ -67,6 +68,57 @@ tape( 'the function calculates the range of a strided array', function test( t ) t.end(); }); +tape( 'the function calculates the range of a sorted strided array (accessor)', function test( t ) { + var x; + var v; + + x = [ -3.0, -2.0, -1.0, 1.0, 2.0, 3.0 ]; + v = range( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + x = [ 3.0, 2.0, 1.0, 0.0, -1.0, -2.0, -3.0 ]; + v = range( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + x = [ -4.0, -5.0 ]; + v = range( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, -4.5, 'returns expected value' ); + + x = [ -4.0, -4.0 ]; + v = range( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, -4.0, 'returns expected value' ); + + x = [ -0.0, -0.0, 0.0 ]; + v = range( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + + x = [ -0.0, -0.0, -0.0, 0.0 ]; + v = range( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + + x = [ 0.0, -0.0, -0.0 ]; + v = range( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = range( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = range( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ 5.0, NaN ]; + v = range( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, 5.0 ]; + v = range( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( isnan( v ), true, '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; @@ -100,7 +152,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0` or `N }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -115,15 +166,56 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]; - N = floor( x.length / 2 ); - v = range( N, x, 2, 0 ); + v = range( 4, x, 2, 0 ); t.strictEqual( v, 6.0, 'returns expected value' ); t.end(); }); +tape( 'the function supports a `stride` parameter (accessor)', function test( t ) { + var x; + var v; + + x = [ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + 3.0, // 2 + 3.0, + 4.0, // 3 + 2.0 + ]; + + v = range( 4, toAccessorArray( x ), 2, 0 ); + + t.strictEqual( v, 2.5, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; + + var x; + var v; + + x = [ + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + 3.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]; + + v = range( 4, x, -2, 6 ); + + t.strictEqual( v, 2.5, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `stride` parameter (accessor)', function test( t ) { var x; var v; @@ -138,8 +230,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - N = floor( x.length / 2 ); - v = range( N, x, -2, 6 ); + v = range( 4, toAccessorArray( x ) -2, 6 ); t.strictEqual( v, 6.0, 'returns expected value' ); t.end(); @@ -162,8 +253,19 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` o t.end(); }); +tape( 'if provided a `stride` parameter equal to `0`, the function returns the first indexed element (accessor)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, -5.0, -6.0 ]; + + v = range( x.length, toAccessorArray( x ), 0, 0 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -177,10 +279,30 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]; - N = floor( x.length / 2 ); - v = range( N, x, 2, 1 ); + v = range( 4, x, 2, 1 ); t.strictEqual( v, 6.0, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `offset` parameter (accessor)', function test( t ) { + var x; + var v; + + x = [ + 2.0, + 1.0, // 0 + 2.0, + 2.0, // 1 + -2.0, + 3.0, // 2 + 3.0, + 4.0 // 3 + ]; + + v = range( 4, toAccessorArray( x ), 2, 1 ); + t.strictEqual( v, 2.5, 'returns expected value' ); + + t.end(); +}); \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js index 6447ea5f2ae3..3aa609d47ab0 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js @@ -21,8 +21,8 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var Float64Array = require( '@stdlib/array/float64' ); var range = require( './../lib/range.js' ); @@ -68,6 +68,19 @@ tape( 'the function calculates the range of a strided array', function test( t ) t.end(); }); +tape( 'the function calculates the range value of a sorted strided array (accessor)', function test( t ) { + function accessor( arr, idx ) { + return arr.get( idx ); + } + + var x = toAccessorArray( new Float64Array( [ -5.0, -2.0, 0.0, 1.0, 3.0, 5.0 ] ) ); + var v = range( x.length, x, accessor, 1 ); + + t.strictEqual( v, 10.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,7 +114,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0` or `N }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -116,15 +128,34 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]; - N = floor( x.length / 2 ); - v = range( N, x, 2 ); + v = range( 4, toAccessorArray( x ), 2 ); t.strictEqual( v, 6.0, 'returns expected value' ); t.end(); }); +tape( 'the function supports a `stride` parameter (accessor)', function test( t ) { + var x; + var v; + + x = [ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + 3.0, // 2 + 3.0, + 4.0, // 3 + 2.0 + ]; + + v = range( 4, toAccessorArray( x ), 2 ); + + t.strictEqual( v, 2.5, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -139,13 +170,33 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - N = floor( x.length / 2 ); - v = range( N, x, -2 ); + v = range( 4, x, -2 ); t.strictEqual( v, 6.0, 'returns expected value' ); t.end(); }); +tape( 'the function supports a negative `stride` parameter (accessor)', function test( t ) { + var x; + var v; + + x = [ + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + 3.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]; + + v = range( 4, toAccessorArray( x ), -2 ); + + t.strictEqual( v, 2.5, 'returns expected value' ); + t.end(); +}); + tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` or `NaN`', function test( t ) { var x; var v; @@ -163,6 +214,18 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` o t.end(); }); +tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element (accessor)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, -5.0, -6.0 ]; + + v = range( x.length, toAccessorArray( x ), 0 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var x0; var x1; @@ -182,10 +245,34 @@ 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 = range( N, x1, 2 ); + v = range( 4, x1, 2 ); t.strictEqual( v, 6.0, 'returns expected value' ); t.end(); }); + +tape( 'the function supports view offsets (accessor)', function test( t ) { + var x0; + var x1; + var v; + + x0 = new Float64Array([ + 2.0, + 1.0, // 0 + 2.0, + 2.0, // 1 + -2.0, + 3.0, // 2 + 3.0, + 4.0, // 3 + 6.0 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + + v = range( 4, toAccessorArray( x1 ), 2 ); + t.strictEqual( v, 2.5, 'returns expected value' ); + + t.end(); +}); \ No newline at end of file From d74bbfd44f2ea4981f9801c077466bf61b8714ca Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 17:57:00 +0530 Subject: [PATCH 03/20] approved --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: failed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- .../@stdlib/stats/base/range/README.md | 4 +- .../base/range/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/stats/base/range/lib/accessors.js | 67 ++++++++----------- .../stats/base/range/test/test.ndarray.js | 30 ++++----- .../stats/base/range/test/test.range.js | 16 ++--- 5 files changed, 54 insertions(+), 65 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/README.md b/lib/node_modules/@stdlib/stats/base/range/README.md index 42e21fd685e1..745ffb8e3782 100644 --- a/lib/node_modules/@stdlib/stats/base/range/README.md +++ b/lib/node_modules/@stdlib/stats/base/range/README.md @@ -59,7 +59,6 @@ The function has the following parameters: The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [range][range] of every other element in `x`, ```javascript - var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ]; var v = range( 4, x, 2 ); @@ -99,7 +98,6 @@ The function has the following additional parameters: 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 calculate the [range][range] for every other value in `x` starting from the second value ```javascript - var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; var v = range.ndarray( 4, x, 2, 1 ); @@ -116,7 +114,7 @@ var v = range.ndarray( 4, x, 2, 1 ); - If `N <= 0`, both functions return `NaN`. - Depending on the environment, the typed versions ([`drange`][@stdlib/stats/base/drange], [`srange`][@stdlib/stats/base/srange], etc.) are likely to be significantly more performant. -- 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]). +- 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]). diff --git a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js index af564a17d3eb..c4f633f914fc 100644 --- a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js @@ -22,7 +22,7 @@ var bench = require( '@stdlib/bench' ); var randu = require( '@stdlib/random/base/randu' ); -var linspace = require( '@stdlib/array/linspace/docs/types/index' ); +var linspace = require( '@stdlib/array/linspace' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js index ba4a7c4cb949..0569ca3e93be 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/range/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. @@ -21,7 +21,7 @@ // MODULES // var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var stride2offset = require( '@stdlib/strided/base/stride2offset' ); + // MAIN // @@ -48,44 +48,35 @@ var stride2offset = require( '@stdlib/strided/base/stride2offset' ); * // returns 4.0 */ function range( N, x, get, stride ) { - var max; - var min; - var ix; - var v; - var i; + if ( N <= 0 ) { + return NaN; + } + if ( N === 1 || stride === 0 ) { + let v = get( x, 0 ); + return isnan( v ) ? NaN : 0.0; + } + + let ix = stride < 0 ? (1 - N) * stride : 0; + let min = get( x, ix ); + let max = min; + + for ( let i = 1; i < N; i++ ) { + ix += stride; + let v = get( x, ix ); - if ( N <= 0 ) { - return NaN; - } - if ( N === 1 || stride === 0 ) { - v = get( x, 0 ); - if ( isnan( v ) ) { - return NaN; - } - return 0.0; - } - if ( stride < 0 ) { - ix = (1 - N) * stride; - } else { - ix = 0; - } - min = get( x, ix ); - max = min; - for ( i = 1; i < N; i++ ) { - ix += stride; - v = get( x, ix ); - if ( isnan( v ) ) { - return v; - } - if ( v < min ) { - min = v; - } else if ( v > max ) { - max = v; - } - } - return max - min; + if ( isnan( v ) ) { + return NaN; + } + if ( v < min ) { + min = v; + } else if ( v > max ) { + max = v; + } + } + return max - min; } + // EXPORTS // -module.exports = range; \ No newline at end of file +module.exports = range; diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js index be0f499471fd..0ad92114b498 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js @@ -74,35 +74,35 @@ tape( 'the function calculates the range of a sorted strided array (accessor)', x = [ -3.0, -2.0, -1.0, 1.0, 2.0, 3.0 ]; v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); + t.ok(isnan(v), 'returns expected value'); x = [ 3.0, 2.0, 1.0, 0.0, -1.0, -2.0, -3.0 ]; v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); + t.ok(isnan(v), 'returns expected value'); x = [ -4.0, -5.0 ]; v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( v, -4.5, 'returns expected value' ); + t.ok(isnan(v), 'returns expected value'); x = [ -4.0, -4.0 ]; v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( v, -4.0, 'returns expected value' ); + t.ok(isnan(v), 'returns expected value'); x = [ -0.0, -0.0, 0.0 ]; v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + t.ok(isnan(v), 'returns expected value'); x = [ -0.0, -0.0, -0.0, 0.0 ]; v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + t.ok(isnan(v), 'returns expected value'); x = [ 0.0, -0.0, -0.0 ]; v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + t.ok(isnan(v), 'returns expected value'); - x = [ NaN ]; - v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); + x = [5.0, 5.0, 5.0]; + v = range(x.length, x, 1, 0); + t.strictEqual(v, 0.0, 'returns expected value'); x = [ NaN, NaN ]; v = range( x.length, toAccessorArray( x ), 1, 0 ); @@ -189,7 +189,7 @@ tape( 'the function supports a `stride` parameter (accessor)', function test( t v = range( 4, toAccessorArray( x ), 2, 0 ); - t.strictEqual( v, 2.5, 'returns expected value' ); + t.ok(isnan(v), 'returns expected value'); t.end(); }); @@ -211,7 +211,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) v = range( 4, x, -2, 6 ); - t.strictEqual( v, 2.5, 'returns expected value' ); + t.strictEqual( v, 3, 'returns expected value' ); t.end(); }); @@ -232,7 +232,7 @@ tape( 'the function supports a negative `stride` parameter (accessor)', function v = range( 4, toAccessorArray( x ) -2, 6 ); - t.strictEqual( v, 6.0, 'returns expected value' ); + t.ok(isnan(v), 'returns expected value'); t.end(); }); @@ -260,7 +260,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f x = [ 1.0, -2.0, -4.0, -5.0, -6.0 ]; v = range( x.length, toAccessorArray( x ), 0, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); + t.strictEqual( v, 0, 'returns expected value' ); t.end(); }); @@ -302,7 +302,7 @@ tape( 'the function supports an `offset` parameter (accessor)', function test( t ]; v = range( 4, toAccessorArray( x ), 2, 1 ); - t.strictEqual( v, 2.5, 'returns expected value' ); + t.ok(isnan(v), 'returns expected value'); t.end(); }); \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js index 3aa609d47ab0..f524309abcee 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js @@ -76,7 +76,7 @@ tape( 'the function calculates the range value of a sorted strided array (access var x = toAccessorArray( new Float64Array( [ -5.0, -2.0, 0.0, 1.0, 3.0, 5.0 ] ) ); var v = range( x.length, x, accessor, 1 ); - t.strictEqual( v, 10.0, 'returns expected value' ); + t.strictEqual(isnan(v), true, 'returns expected value'); t.end(); }); @@ -130,7 +130,7 @@ tape( 'the function supports a `stride` parameter', function test( t ) { v = range( 4, toAccessorArray( x ), 2 ); - t.strictEqual( v, 6.0, 'returns expected value' ); + t.strictEqual(isnan(v), true, 'returns expected value'); t.end(); }); @@ -151,7 +151,7 @@ tape( 'the function supports a `stride` parameter (accessor)', function test( t v = range( 4, toAccessorArray( x ), 2 ); - t.strictEqual( v, 2.5, 'returns expected value' ); + t.strictEqual(isnan(v), true, 'returns expected value'); t.end(); }); @@ -172,7 +172,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) v = range( 4, x, -2 ); - t.strictEqual( v, 6.0, 'returns expected value' ); + t.strictEqual(v, 6, 'returns expected value'); t.end(); }); @@ -193,7 +193,7 @@ tape( 'the function supports a negative `stride` parameter (accessor)', function v = range( 4, toAccessorArray( x ), -2 ); - t.strictEqual( v, 2.5, 'returns expected value' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -221,7 +221,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f x = [ 1.0, -2.0, -4.0, -5.0, -6.0 ]; v = range( x.length, toAccessorArray( x ), 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); + t.strictEqual(isnan(v), false, 'returns expected value'); t.end(); }); @@ -269,10 +269,10 @@ tape( 'the function supports view offsets (accessor)', function test( t ) { 6.0 ]); - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); v = range( 4, toAccessorArray( x1 ), 2 ); - t.strictEqual( v, 2.5, 'returns expected value' ); + t.strictEqual(isnan(v), true, 'returns expected value'); t.end(); }); \ No newline at end of file From 5d543eded9fa68f5785b11773c0abf4befe0df97 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 20:46:28 +0530 Subject: [PATCH 04/20] lint error --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- .../@stdlib/stats/base/range/docs/repl.txt | 51 ++++++++++++--- .../@stdlib/stats/base/range/lib/accessors.js | 10 +-- .../@stdlib/stats/base/range/lib/ndarray.js | 62 +++++++++---------- .../stats/base/range/test/test.ndarray.js | 2 +- .../stats/base/range/test/test.range.js | 18 +++--- 5 files changed, 89 insertions(+), 54 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index 2b1569979610..467948635298 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -1,44 +1,61 @@ - {{alias}}( N, x, strideX ) + + Computes the range of a strided array. - 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 a typed - array view. + 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 a + typed array view. + If `N <= 0`, the function returns `NaN`. + Parameters ---------- + + N: integer Number of indexed elements. + x: Array|TypedArray Input array. + strideX: integer Stride length. + Returns ------- + + out: number Range. + Examples -------- + + // Standard Usage: > var x = [ 1.0, -2.0, 2.0 ]; > {{alias}}( x.length, x, 1 ) 4.0 + // Using `N` and stride parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; > var stride = 2; > {{alias}}( 3, x, stride ) 4.0 + // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); @@ -46,44 +63,62 @@ > {{alias}}( 3, x1, stride ) 4.0 + {{alias}}.ndarray( N, x, strideX, offsetX ) - Computes the range of a strided array using alternative indexing semantics. + + + Computes the range of a strided array 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 starting index. + Parameters ---------- + + N: integer Number of indexed elements. + x: Array|TypedArray Input array. + strideX: integer Stride length. + offsetX: integer Starting index. + Returns ------- + + out: number Range. + Examples -------- + + // Standard Usage: > var x = [ 1.0, -2.0, 2.0 ]; > {{alias}}.ndarray( x.length, x, 1, 0 ) 4.0 + // Using offset parameter: > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; > {{alias}}.ndarray( 3, x, 2, 1 ) 4.0 - See Also - -------- + See Also + -------- \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js index 0569ca3e93be..eca83e65282c 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js @@ -52,17 +52,17 @@ function range( N, x, get, stride ) { return NaN; } if ( N === 1 || stride === 0 ) { - let v = get( x, 0 ); - return isnan( v ) ? NaN : 0.0; + const v = get( x, 0 ); + return ( isnan(v) ) ? NaN : 0.0; } - - let ix = stride < 0 ? (1 - N) * stride : 0; + + let ix = ( stride < 0 ) ? ( ( 1 - N ) * stride ) : 0; let min = get( x, ix ); let max = min; for ( let i = 1; i < N; i++ ) { ix += stride; - let v = get( x, ix ); + const v = get( x, ix ); if ( isnan( v ) ) { return NaN; diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js index 4e8e163bc6c0..bbb070bc06b6 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js @@ -45,40 +45,40 @@ var accessors = require( './accessors.js' ); * // returns 6.0 */ function range( N, x, strideX, offsetX ) { - var obj = arraylike2object( x ); // Convert input to object with `data` property - var data = obj.data; // Extract data directly + var obj = arraylike2object( x ); + var data = obj.data; - var max; - var min; - var ix; - var v; - var i; + var max; + var min; + var ix; + var v; + var i; - if ( N <= 0 ) { - return NaN; - } - if ( N === 1 || strideX === 0 ) { - v = data[offsetX]; // Direct access instead of using an accessor function - return isnan( v ) ? NaN : 0.0; - } - ix = offsetX; - min = data[ix]; // Direct access - max = min; - for ( i = 1; i < N; i++ ) { - ix += strideX; - v = data[ix]; // Direct access - if ( isnan( v ) ) { - return v; - } - if ( v < min ) { - min = v; - } else if ( v > max ) { - max = v; - } - } - return max - min; + if ( N <= 0 ) { + return NaN; + } + if ( N === 1 || strideX === 0 ) { + v = data[offsetX]; // Direct access instead of using an accessor function + return isnan( v ) ? NaN : 0.0; + } + ix = offsetX; + min = data[ix]; // Direct access + max = min; + for ( i = 1; i < N; i++ ) { + ix += strideX; + v = data[ix]; // Direct access + if ( isnan( v ) ) { + return v; + } + if ( v < min ) { + min = v; + } else if ( v > max ) { + max = v; + } + } + return max - min; } // EXPORTS // -module.exports = range; \ No newline at end of file +module.exports = range; diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js index 0ad92114b498..2bbf9f285950 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js @@ -305,4 +305,4 @@ tape( 'the function supports an `offset` parameter (accessor)', function test( t t.ok(isnan(v), 'returns expected value'); t.end(); -}); \ No newline at end of file +}); diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js index f524309abcee..896d1aa693ed 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js @@ -69,15 +69,15 @@ tape( 'the function calculates the range of a strided array', function test( t ) }); tape( 'the function calculates the range value of a sorted strided array (accessor)', function test( t ) { - function accessor( arr, idx ) { - return arr.get( idx ); - } + function accessor( arr, idx ) { + return arr.get( idx ); + } - var x = toAccessorArray( new Float64Array( [ -5.0, -2.0, 0.0, 1.0, 3.0, 5.0 ] ) ); - var v = range( x.length, x, accessor, 1 ); + var x = toAccessorArray( new Float64Array( [ -5.0, -2.0, 0.0, 1.0, 3.0, 5.0 ] ) ); + var v = range( x.length, x, accessor, 1 ); - t.strictEqual(isnan(v), true, 'returns expected value'); - t.end(); + t.strictEqual(isnan(v), true, 'returns expected value'); + t.end(); }); @@ -269,10 +269,10 @@ tape( 'the function supports view offsets (accessor)', function test( t ) { 6.0 ]); - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); v = range( 4, toAccessorArray( x1 ), 2 ); t.strictEqual(isnan(v), true, 'returns expected value'); t.end(); -}); \ No newline at end of file +}); From 165db0404ba8029d4dea29166f9c09cf7486c583 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 17:53:55 +0530 Subject: [PATCH 05/20] changes --- .../@stdlib/stats/base/range/README.md | 6 +- .../stats/base/range/benchmark/benchmark.js | 6 +- .../base/range/benchmark/benchmark.ndarray.js | 7 +- .../@stdlib/stats/base/range/docs/repl.txt | 43 +---- .../stats/base/range/examples/index.js | 7 +- .../@stdlib/stats/base/range/lib/accessors.js | 86 +++++----- .../@stdlib/stats/base/range/lib/ndarray.js | 28 ++-- .../@stdlib/stats/base/range/lib/range.js | 1 - .../stats/base/range/test/test.ndarray.js | 148 ++++-------------- .../stats/base/range/test/test.range.js | 75 +-------- 10 files changed, 117 insertions(+), 290 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/README.md b/lib/node_modules/@stdlib/stats/base/range/README.md index 745ffb8e3782..465497f284e8 100644 --- a/lib/node_modules/@stdlib/stats/base/range/README.md +++ b/lib/node_modules/@stdlib/stats/base/range/README.md @@ -127,15 +127,17 @@ var v = range.ndarray( 4, x, 2, 1 ); ```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); -var linspace = require( '@stdlib/array/base/linspace' ); var range = require( '@stdlib/stats/base/range' ); var x; var i; -x = linspace(-50, 50, 10); +x = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); x = x.map(round); console.log( x ); diff --git a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js index df0bb51f350c..4e64b2aac601 100644 --- a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.js @@ -21,8 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var linspace = require( '@stdlib/array/base/linspace' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; var range = require( './../lib/range.js' ); @@ -38,7 +38,9 @@ var range = require( './../lib/range.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = linspace( 0.0, len, len ); + var x = discreteUniform(len, 0, len, { + 'dtype': 'float64' + }); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js index c4f633f914fc..3fcc163909c1 100644 --- a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); -var linspace = require( '@stdlib/array/linspace' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; @@ -40,7 +39,9 @@ var range = require( './../lib/ndarray.js' ); */ function createBenchmark( len ) { var x; - var x = linspace( 0.0, len, len ); + var x = discreteUniform(len, 0, len, { + 'dtype': 'float64' + }); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index 467948635298..7ff07c792955 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -1,124 +1,91 @@ -{{alias}}( N, x, strideX ) - +{{alias}}( N, x, strideX ) Computes the range of a strided array. - 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 a typed array view. - If `N <= 0`, the function returns `NaN`. - Parameters ---------- - - N: integer Number of indexed elements. - x: Array|TypedArray Input array. - strideX: integer Stride length. - Returns ------- - - out: number Range. - Examples -------- - - // Standard Usage: > var x = [ 1.0, -2.0, 2.0 ]; > {{alias}}( x.length, x, 1 ) 4.0 - // Using `N` and stride parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; > var stride = 2; > {{alias}}( 3, x, stride ) 4.0 - // Using view offsets: - > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); - > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var x0 = new {{alias:@stdlib/array/float64}} + ( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}} + ( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > stride = 2; > {{alias}}( 3, x1, stride ) 4.0 - {{alias}}.ndarray( N, x, strideX, offsetX ) - - Computes the range of a strided array 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 starting index. - Parameters ---------- - - N: integer Number of indexed elements. - x: Array|TypedArray Input array. - strideX: integer Stride length. - offsetX: integer Starting index. - Returns ------- - - out: number Range. - Examples -------- - - // Standard Usage: > var x = [ 1.0, -2.0, 2.0 ]; > {{alias}}.ndarray( x.length, x, 1, 0 ) 4.0 - // Using offset parameter: > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; > {{alias}}.ndarray( 3, x, 2, 1 ) 4.0 - See Also -------- \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/range/examples/index.js b/lib/node_modules/@stdlib/stats/base/range/examples/index.js index 168401689aed..b1f8f06bbd77 100644 --- a/lib/node_modules/@stdlib/stats/base/range/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/range/examples/index.js @@ -18,10 +18,13 @@ 'use strict'; -var linspace = require( '@stdlib/array/base/linspace' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var range = require( './../lib' ); -var x = linspace(-50, 50, 10); +var len = 50; +var x = discreteUniform(len, 0, len, { + 'dtype': 'float64' +}); console.log( x ); var v = range( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js index eca83e65282c..db1c287a609d 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js @@ -26,57 +26,57 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); // MAIN // /** -* Computes the range of a strided array using the accessor protocol. +* Computes the range of a strided array using accessors. * +* @private * @param {PositiveInteger} N - number of indexed elements -* @param {Object} x - input array-like object supporting the accessor protocol -* @param {Function} get - accessor function to retrieve array values -* @param {integer} stride - stride length -* @returns {number} range (max - min) -* -* @example -* function accessor( arr, idx ) { -* return arr.get( idx ); -* } -* -* var x = { -* data: [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ], -* get: function( i ) { return this.data[ i ]; } -* }; -* -* var v = range( 3, x, accessor, 2 ); -* // returns 4.0 +* @param {Object} obj - input array object +* @param {integer} strideX - strideX length +* @param {NonNegativeInteger} offsetX - starting index +* @returns {number} range */ -function range( N, x, get, stride ) { - if ( N <= 0 ) { - return NaN; - } - if ( N === 1 || stride === 0 ) { - const v = get( x, 0 ); - return ( isnan(v) ) ? NaN : 0.0; - } +function range( N, x, strideX, offsetX ) { + var xbuf; + var xget; + var ix; + var min; + var max; + var v; + var i; - let ix = ( stride < 0 ) ? ( ( 1 - N ) * stride ) : 0; - let min = get( x, ix ); - let max = min; + // Cache references to array data: + xbuf = x.data; - for ( let i = 1; i < N; i++ ) { - ix += stride; - const v = get( x, ix ); + // Cache references to element accessors: + xget = x.accessors[ 0 ]; - if ( isnan( v ) ) { - return NaN; - } - if ( v < min ) { - min = v; - } else if ( v > max ) { - max = v; - } - } - return max - min; + if ( N === 1 || strideX === 0 ) { + v = xget( xbuf, offsetX ); + return ( isnan( v ) ) ? NaN : 0.0; + } + ix = offsetX; + v = xget( xbuf, ix ); + if ( isnan( v ) ) { + return NaN; + } + min = v; + max = v; + for ( i = 1; i < N; i++ ) { + ix += strideX; + v = xget( xbuf, ix ); + if ( isnan( v ) ) { + return NaN; + } + if ( v < min ) { + min = v; + } else if ( v > max ) { + max = v; + } + } + return max - min; } // EXPORTS // -module.exports = range; +module.exports = range; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js index bbb070bc06b6..5da9ed43c0bc 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/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. @@ -24,6 +24,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); var accessors = require( './accessors.js' ); + // MAIN // /** @@ -31,8 +32,8 @@ var accessors = require( './accessors.js' ); * * @param {PositiveInteger} N - number of indexed elements * @param {NumericArray} x - input array -* @param {integer} strideX - strideX length -* @param {NonNegativeInteger} offsetX - starting index +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` * @returns {number} range * * @example @@ -45,28 +46,32 @@ var accessors = require( './accessors.js' ); * // returns 6.0 */ function range( N, x, strideX, offsetX ) { - var obj = arraylike2object( x ); - var data = obj.data; - var max; var min; var ix; + var o; var v; var i; if ( N <= 0 ) { return NaN; } + o = arraylike2object( x ); + if ( o.accessorProtocol ) { + return accessors( N, o, strideX, offsetX ); + } if ( N === 1 || strideX === 0 ) { - v = data[offsetX]; // Direct access instead of using an accessor function - return isnan( v ) ? NaN : 0.0; + if ( isnan( x[ offsetX ] ) ) { + return NaN; + } + return 0.0; } ix = offsetX; - min = data[ix]; // Direct access + min = x[ ix ]; max = min; for ( i = 1; i < N; i++ ) { ix += strideX; - v = data[ix]; // Direct access + v = x[ ix ]; if ( isnan( v ) ) { return v; } @@ -79,6 +84,7 @@ function range( N, x, strideX, offsetX ) { return max - min; } + // EXPORTS // -module.exports = range; +module.exports = range; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/range.js b/lib/node_modules/@stdlib/stats/base/range/lib/range.js index 75af008ffba7..bcce468ecfe3 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/range.js +++ b/lib/node_modules/@stdlib/stats/base/range/lib/range.js @@ -20,7 +20,6 @@ // MODULES // -var isnan = require( '@stdlib/math/base/assert/is-nan' ); var stride2offset = require( '@stdlib/strided/base/stride2offset' ); var ndarray = require( './ndarray.js' ); diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js index 2bbf9f285950..f92e5d7658c2 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js @@ -22,10 +22,8 @@ var tape = require( 'tape' ); 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 range = require( './../lib/ndarray.js' ); -var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); // TESTS // @@ -57,81 +55,46 @@ tape( 'the function calculates the range of a strided array', function test( t ) v = range( x.length, x, 1, 0 ); t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); - x = [ NaN ]; - v = range( x.length, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - x = [ NaN, NaN ]; - v = range( x.length, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - t.end(); }); -tape( 'the function calculates the range of a sorted strided array (accessor)', function test( t ) { - var x; - var v; - - x = [ -3.0, -2.0, -1.0, 1.0, 2.0, 3.0 ]; - v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.ok(isnan(v), 'returns expected value'); - - x = [ 3.0, 2.0, 1.0, 0.0, -1.0, -2.0, -3.0 ]; - v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.ok(isnan(v), 'returns expected value'); +tape('the function calculates the range of a sorted strided array (accessor)', function test(t) { + var x; + var v; - x = [ -4.0, -5.0 ]; - v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.ok(isnan(v), 'returns expected value'); - - x = [ -4.0, -4.0 ]; - v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.ok(isnan(v), 'returns expected value'); - - x = [ -0.0, -0.0, 0.0 ]; - v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.ok(isnan(v), 'returns expected value'); - - x = [ -0.0, -0.0, -0.0, 0.0 ]; - v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.ok(isnan(v), 'returns expected value'); + x = [-3.0, -2.0, -1.0, 1.0, 2.0, 3.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(v, 6.0, 'returns expected value'); - x = [ 0.0, -0.0, -0.0 ]; - v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.ok(isnan(v), 'returns expected value'); + x = [3.0, 2.0, 1.0, 0.0, -1.0, -2.0, -3.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(v, 6.0, 'returns expected value'); - x = [5.0, 5.0, 5.0]; - v = range(x.length, x, 1, 0); - t.strictEqual(v, 0.0, 'returns expected value'); + x = [-4.0, -5.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(v, 1.0, 'returns expected value'); - x = [ NaN, NaN ]; - v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - x = [ 5.0, NaN ]; - v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - x = [ NaN, 5.0 ]; - v = range( x.length, toAccessorArray( x ), 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - - t.end(); -}); + x = [-4.0, -4.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(v, 0.0, 'returns expected value'); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { - var x; - var v; + x = [-0.0, -0.0, 0.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(isPositiveZero(v), true, 'returns expected value'); - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + x = [-0.0, -0.0, -0.0, 0.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(isPositiveZero(v), true, 'returns expected value'); - v = range( 0, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); + x = [0.0, -0.0, -0.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(isPositiveZero(v), true, 'returns expected value'); - v = range( -1, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); + x = [5.0, 5.0, 5.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(v, 0.0, 'returns expected value'); - t.end(); + t.end(); }); tape( 'if provided an `N` parameter equal to `1`, the function returns `0` or `NaN`', function test( t ) { @@ -142,12 +105,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0` or `N v = range( 1, x, 1, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, -2.0, -4.0, 5.0, 3.0 ]; - - v = range( 1, x, 1, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - t.end(); }); @@ -172,27 +129,6 @@ tape( 'the function supports a `stride` parameter', function test( t ) { t.end(); }); -tape( 'the function supports a `stride` parameter (accessor)', function test( t ) { - var x; - var v; - - x = [ - 1.0, // 0 - 2.0, - 2.0, // 1 - -7.0, - 3.0, // 2 - 3.0, - 4.0, // 3 - 2.0 - ]; - - v = range( 4, toAccessorArray( x ), 2, 0 ); - - t.ok(isnan(v), 'returns expected value'); - t.end(); -}); - tape( 'the function supports a negative `stride` parameter', function test( t ) { var x; @@ -215,26 +151,6 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) t.end(); }); -tape( 'the function supports a negative `stride` parameter (accessor)', function test( t ) { - var x; - var v; - - x = [ - 1.0, // 3 - 2.0, - 2.0, // 2 - -7.0, - -2.0, // 1 - 3.0, - 4.0, // 0 - 2.0 - ]; - - v = range( 4, toAccessorArray( x ) -2, 6 ); - - t.ok(isnan(v), 'returns expected value'); - t.end(); -}); tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` or `NaN`', function test( t ) { var x; @@ -244,12 +160,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` o v = range( x.length, x, 0, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); - - x = [ NaN, -2.0, -4.0, 5.0, 3.0 ]; - - v = range( x.length, x, 0, 0 ); - t.strictEqual( isnan( v ), true, 'returns expected value' ); - t.end(); }); @@ -302,7 +212,7 @@ tape( 'the function supports an `offset` parameter (accessor)', function test( t ]; v = range( 4, toAccessorArray( x ), 2, 1 ); - t.ok(isnan(v), 'returns expected value'); + t.ok( v, 3.0, 'returns expected value'); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js index 896d1aa693ed..a40240d4e5fd 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); @@ -114,6 +115,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0` or `N }); tape( 'the function supports a `stride` parameter', function test( t ) { + var N; var x; var v; @@ -128,30 +130,10 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]; - v = range( 4, toAccessorArray( x ), 2 ); - - t.strictEqual(isnan(v), true, 'returns expected value'); - t.end(); -}); - -tape( 'the function supports a `stride` parameter (accessor)', function test( t ) { - var x; - var v; + N = floor( x.length / 2 ); + v = range( N, x, 2 ); - x = [ - 1.0, // 0 - 2.0, - 2.0, // 1 - -7.0, - 3.0, // 2 - 3.0, - 4.0, // 3 - 2.0 - ]; - - v = range( 4, toAccessorArray( x ), 2 ); - - t.strictEqual(isnan(v), true, 'returns expected value'); + t.strictEqual( v, 6.0, 'returns expected value' ); t.end(); }); @@ -176,27 +158,6 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) t.end(); }); -tape( 'the function supports a negative `stride` parameter (accessor)', function test( t ) { - var x; - var v; - - x = [ - 1.0, // 3 - 2.0, - 2.0, // 2 - -7.0, - 3.0, // 1 - 3.0, - 4.0, // 0 - 2.0 - ]; - - v = range( 4, toAccessorArray( x ), -2 ); - - t.strictEqual( isnan( v ), true, 'returns expected value' ); - t.end(); -}); - tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` or `NaN`', function test( t ) { var x; var v; @@ -244,7 +205,7 @@ tape( 'the function supports view offsets', function test( t ) { 6.0 ]); - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); v = range( 4, x1, 2 ); t.strictEqual( v, 6.0, 'returns expected value' ); @@ -252,27 +213,3 @@ tape( 'the function supports view offsets', function test( t ) { t.end(); }); -tape( 'the function supports view offsets (accessor)', function test( t ) { - var x0; - var x1; - var v; - - x0 = new Float64Array([ - 2.0, - 1.0, // 0 - 2.0, - 2.0, // 1 - -2.0, - 3.0, // 2 - 3.0, - 4.0, // 3 - 6.0 - ]); - - x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - - v = range( 4, toAccessorArray( x1 ), 2 ); - t.strictEqual(isnan(v), true, 'returns expected value'); - - t.end(); -}); From ac356d16fb2b0db50ce7059b7fd21bdb023fd6c6 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 18:07:43 +0530 Subject: [PATCH 06/20] check --- lib/node_modules/@stdlib/stats/base/range/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/README.md b/lib/node_modules/@stdlib/stats/base/range/README.md index 465497f284e8..b7405e2d47a1 100644 --- a/lib/node_modules/@stdlib/stats/base/range/README.md +++ b/lib/node_modules/@stdlib/stats/base/range/README.md @@ -135,8 +135,8 @@ var range = require( '@stdlib/stats/base/range' ); var x; var i; -x = discreteUniform( 10, -50, 50, { - 'dtype': 'float64' +x = discreteUniform(10, -50, 50, { + 'dtype': 'float64' }); x = x.map(round); console.log( x ); From 34f7be02ff3ecbe72cbed999e227f41352039048 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 18:11:00 +0530 Subject: [PATCH 07/20] check --- lib/node_modules/@stdlib/stats/base/range/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/README.md b/lib/node_modules/@stdlib/stats/base/range/README.md index b7405e2d47a1..ffd2047a57f7 100644 --- a/lib/node_modules/@stdlib/stats/base/range/README.md +++ b/lib/node_modules/@stdlib/stats/base/range/README.md @@ -136,7 +136,7 @@ var x; var i; x = discreteUniform(10, -50, 50, { - 'dtype': 'float64' + 'dtype': 'float64' }); x = x.map(round); console.log( x ); From 888de285ca7c147e3004803dab148fb0a6630d49 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 18:27:46 +0530 Subject: [PATCH 08/20] linting error --- .../@stdlib/stats/base/range/docs/repl.txt | 8 +- .../stats/base/range/examples/index.js | 2 +- .../@stdlib/stats/base/range/lib/accessors.js | 64 +++---- .../@stdlib/stats/base/range/lib/ndarray.js | 2 +- .../stats/base/range/test/test.ndarray.js | 174 +++++++++--------- 5 files changed, 124 insertions(+), 126 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index 7ff07c792955..bdc293d49bf9 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -2,10 +2,10 @@ {{alias}}( N, x, strideX ) Computes the range of a strided array. - The `N` and stride parameters determine which elements in the strided + 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 a + Indexing is relative to the first index. To introduce an offset, use a typed array view. If `N <= 0`, the function returns `NaN`. @@ -49,7 +49,7 @@ 4.0 {{alias}}.ndarray( N, x, strideX, offsetX ) - Computes the range of a strided array using alternative indexing + Computes the range of a strided array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying @@ -88,4 +88,4 @@ 4.0 See Also - -------- \ No newline at end of file + -------- diff --git a/lib/node_modules/@stdlib/stats/base/range/examples/index.js b/lib/node_modules/@stdlib/stats/base/range/examples/index.js index b1f8f06bbd77..28f34170d10f 100644 --- a/lib/node_modules/@stdlib/stats/base/range/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/range/examples/index.js @@ -23,7 +23,7 @@ var range = require( './../lib' ); var len = 50; var x = discreteUniform(len, 0, len, { - 'dtype': 'float64' + 'dtype': 'float64' }); console.log( x ); diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js index db1c287a609d..76f855c2085c 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js @@ -36,13 +36,13 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * @returns {number} range */ function range( N, x, strideX, offsetX ) { - var xbuf; - var xget; - var ix; - var min; - var max; - var v; - var i; + var xbuf; + var xget; + var ix; + var min; + var max; + var v; + var i; // Cache references to array data: xbuf = x.data; @@ -50,33 +50,33 @@ function range( N, x, strideX, offsetX ) { // Cache references to element accessors: xget = x.accessors[ 0 ]; - if ( N === 1 || strideX === 0 ) { - v = xget( xbuf, offsetX ); - return ( isnan( v ) ) ? NaN : 0.0; - } - ix = offsetX; - v = xget( xbuf, ix ); - if ( isnan( v ) ) { - return NaN; - } - min = v; - max = v; - for ( i = 1; i < N; i++ ) { - ix += strideX; - v = xget( xbuf, ix ); - if ( isnan( v ) ) { - return NaN; - } - if ( v < min ) { - min = v; - } else if ( v > max ) { - max = v; - } - } - return max - min; + if ( N === 1 || strideX === 0 ) { + v = xget( xbuf, offsetX ); + return ( isnan( v ) ) ? NaN : 0.0; + } + ix = offsetX; + v = xget( xbuf, ix ); + if ( isnan( v ) ) { + return NaN; + } + min = v; + max = v; + for ( i = 1; i < N; i++ ) { + ix += strideX; + v = xget( xbuf, ix ); + if ( isnan( v ) ) { + return NaN; + } + if ( v < min ) { + min = v; + } else if ( v > max ) { + max = v; + } + } + return max - min; } // EXPORTS // -module.exports = range; \ No newline at end of file +module.exports = range; diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js index 5da9ed43c0bc..a3ec007bc9f4 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/lib/ndarray.js @@ -87,4 +87,4 @@ function range( N, x, strideX, offsetX ) { // EXPORTS // -module.exports = range; \ No newline at end of file +module.exports = range; diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js index f92e5d7658c2..0f730efcce58 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js @@ -1,114 +1,114 @@ /** -* @license Apache-2.0 -* -* 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. -* 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. -*/ + * @license Apache-2.0 + * + * 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. + * 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 tape = require( 'tape' ); -var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); -var range = require( './../lib/ndarray.js' ); +var tape = require('tape'); +var toAccessorArray = require('@stdlib/array/base/to-accessor-array'); +var isPositiveZero = require('@stdlib/math/base/assert/is-positive-zero'); +var range = require('./../lib/ndarray.js'); // TESTS // -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof range, 'function', 'main export is a function' ); +tape('main export is a function', function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof range, 'function', 'main export is a function'); t.end(); }); -tape( 'the function has an arity of 4', function test( t ) { - t.strictEqual( range.length, 4, 'has expected arity' ); +tape('the function has an arity of 4', function test(t) { + t.strictEqual(range.length, 4, 'has expected arity'); t.end(); }); -tape( 'the function calculates the range of a strided array', function test( t ) { +tape('the function calculates the range of a strided array', function test(t) { var x; var v; - x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]; - v = range( x.length, x, 1, 0 ); - t.strictEqual( v, 9.0, 'returns expected value' ); + x = [1.0, -2.0, -4.0, 5.0, 0.0, 3.0]; + v = range(x.length, x, 1, 0); + t.strictEqual(v, 9.0, 'returns expected value'); - x = [ -4.0, -5.0 ]; - v = range( x.length, x, 1, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); + x = [-4.0, -5.0]; + v = range(x.length, x, 1, 0); + t.strictEqual(v, 1.0, 'returns expected value'); - x = [ -0.0, 0.0, -0.0 ]; - v = range( x.length, x, 1, 0 ); - t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + x = [-0.0, 0.0, -0.0]; + v = range(x.length, x, 1, 0); + t.strictEqual(isPositiveZero(v), true, 'returns expected value'); t.end(); }); tape('the function calculates the range of a sorted strided array (accessor)', function test(t) { - var x; - var v; + var x; + var v; - x = [-3.0, -2.0, -1.0, 1.0, 2.0, 3.0]; - v = range(x.length, toAccessorArray(x), 1, 0); - t.strictEqual(v, 6.0, 'returns expected value'); + x = [-3.0, -2.0, -1.0, 1.0, 2.0, 3.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(v, 6.0, 'returns expected value'); - x = [3.0, 2.0, 1.0, 0.0, -1.0, -2.0, -3.0]; - v = range(x.length, toAccessorArray(x), 1, 0); - t.strictEqual(v, 6.0, 'returns expected value'); + x = [3.0, 2.0, 1.0, 0.0, -1.0, -2.0, -3.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(v, 6.0, 'returns expected value'); - x = [-4.0, -5.0]; - v = range(x.length, toAccessorArray(x), 1, 0); - t.strictEqual(v, 1.0, 'returns expected value'); + x = [-4.0, -5.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(v, 1.0, 'returns expected value'); - x = [-4.0, -4.0]; - v = range(x.length, toAccessorArray(x), 1, 0); - t.strictEqual(v, 0.0, 'returns expected value'); + x = [-4.0, -4.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(v, 0.0, 'returns expected value'); - x = [-0.0, -0.0, 0.0]; - v = range(x.length, toAccessorArray(x), 1, 0); - t.strictEqual(isPositiveZero(v), true, 'returns expected value'); + x = [-0.0, -0.0, 0.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(isPositiveZero(v), true, 'returns expected value'); - x = [-0.0, -0.0, -0.0, 0.0]; - v = range(x.length, toAccessorArray(x), 1, 0); - t.strictEqual(isPositiveZero(v), true, 'returns expected value'); + x = [-0.0, -0.0, -0.0, 0.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(isPositiveZero(v), true, 'returns expected value'); - x = [0.0, -0.0, -0.0]; - v = range(x.length, toAccessorArray(x), 1, 0); - t.strictEqual(isPositiveZero(v), true, 'returns expected value'); + x = [0.0, -0.0, -0.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(isPositiveZero(v), true, 'returns expected value'); - x = [5.0, 5.0, 5.0]; - v = range(x.length, toAccessorArray(x), 1, 0); - t.strictEqual(v, 0.0, 'returns expected value'); + x = [5.0, 5.0, 5.0]; + v = range(x.length, toAccessorArray(x), 1, 0); + t.strictEqual(v, 0.0, 'returns expected value'); - t.end(); + t.end(); }); -tape( 'if provided an `N` parameter equal to `1`, the function returns `0` or `NaN`', function test( t ) { +tape('if provided an `N` parameter equal to `1`, the function returns `0` or `NaN`', function test(t) { var x; var v; - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + x = [1.0, -2.0, -4.0, 5.0, 3.0]; - v = range( 1, x, 1, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); + v = range(1, x, 1, 0); + t.strictEqual(v, 0.0, 'returns expected value'); t.end(); }); -tape( 'the function supports a `stride` parameter', function test( t ) { +tape('the function supports a `stride` parameter', function test(t) { var x; var v; @@ -123,14 +123,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]; - v = range( 4, x, 2, 0 ); + v = range(4, x, 2, 0); - t.strictEqual( v, 6.0, 'returns expected value' ); + t.strictEqual(v, 6.0, 'returns expected value'); t.end(); }); -tape( 'the function supports a negative `stride` parameter', function test( t ) { - +tape('the function supports a negative `stride` parameter', function test(t) { var x; var v; @@ -145,37 +144,36 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - v = range( 4, x, -2, 6 ); + v = range(4, x, -2, 6); - t.strictEqual( v, 3, 'returns expected value' ); + t.strictEqual(v, 3, 'returns expected value'); t.end(); }); - -tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` or `NaN`', function test( t ) { +tape('if provided a `stride` parameter equal to `0`, the function returns `0` or `NaN`', function test(t) { var x; var v; - x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + x = [1.0, -2.0, -4.0, 5.0, 3.0]; - v = range( x.length, x, 0, 0 ); - t.strictEqual( v, 0.0, 'returns expected value' ); + v = range(x.length, x, 0, 0); + t.strictEqual(v, 0.0, 'returns expected value'); t.end(); }); -tape( 'if provided a `stride` parameter equal to `0`, the function returns the first indexed element (accessor)', function test( t ) { +tape('if provided a `stride` parameter equal to `0`, the function returns the first indexed element (accessor)', function test(t) { var x; var v; - x = [ 1.0, -2.0, -4.0, -5.0, -6.0 ]; + x = [1.0, -2.0, -4.0, -5.0, -6.0]; - v = range( x.length, toAccessorArray( x ), 0, 0 ); - t.strictEqual( v, 0, 'returns expected value' ); + v = range(x.length, toAccessorArray(x), 0, 0); + t.strictEqual(v, 0, 'returns expected value'); t.end(); }); -tape( 'the function supports an `offset` parameter', function test( t ) { +tape('the function supports an `offset` parameter', function test(t) { var x; var v; @@ -190,13 +188,13 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 4.0 // 3 ]; - v = range( 4, x, 2, 1 ); - t.strictEqual( v, 6.0, 'returns expected value' ); + v = range(4, x, 2, 1); + t.strictEqual(v, 6.0, 'returns expected value'); t.end(); }); -tape( 'the function supports an `offset` parameter (accessor)', function test( t ) { +tape('the function supports an `offset` parameter (accessor)', function test(t) { var x; var v; @@ -211,8 +209,8 @@ tape( 'the function supports an `offset` parameter (accessor)', function test( t 4.0 // 3 ]; - v = range( 4, toAccessorArray( x ), 2, 1 ); - t.ok( v, 3.0, 'returns expected value'); + v = range(4, toAccessorArray(x), 2, 1); + t.ok(v, 3.0, 'returns expected value'); t.end(); }); From 7bbc2db995b42410f5352ebb6ca74cd35b609afa Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 18:37:49 +0530 Subject: [PATCH 09/20] repl --- .../@stdlib/stats/base/range/docs/repl.txt | 21 ++++++++++++++----- .../@stdlib/stats/base/range/lib/accessors.js | 6 +++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index bdc293d49bf9..5df3e54b2dcb 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -15,7 +15,7 @@ N: integer Number of indexed elements. - x: Array|TypedArray + x: Array | TypedArray Input array. strideX: integer @@ -39,15 +39,21 @@ > {{alias}}( 3, x, stride ) 4.0 + // Handling `N <= 0` case: + > x = [ 1.0, -2.0, 2.0 ]; + > {{alias}}( 0, x, 1 ) + NaN + // Using view offsets: - > var x0 = new {{alias:@stdlib/array/float64}} + > var x0 = new ({{alias:@stdlib/array/float64}}) ( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); - > var x1 = new {{alias:@stdlib/array/float64}} - ( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var x1 = new ({{alias:@stdlib/array/float64}}) + ( x0.buffer, x0.BYTES_PER_ELEMENT * 1 ); > stride = 2; > {{alias}}( 3, x1, stride ) 4.0 + {{alias}}.ndarray( N, x, strideX, offsetX ) Computes the range of a strided array using alternative indexing semantics. @@ -61,7 +67,7 @@ N: integer Number of indexed elements. - x: Array|TypedArray + x: Array | TypedArray Input array. strideX: integer @@ -87,5 +93,10 @@ > {{alias}}.ndarray( 3, x, 2, 1 ) 4.0 + // Handling `N <= 0` case: + > x = [ 1.0, -2.0, 2.0 ]; + > {{alias}}.ndarray( 0, x, 1, 0 ) + NaN + See Also -------- diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js index 76f855c2085c..08bbb4475f81 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js @@ -35,7 +35,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * @param {NonNegativeInteger} offsetX - starting index * @returns {number} range */ -function range( N, x, strideX, offsetX ) { +function range( N, obj, strideX, offsetX ) { var xbuf; var xget; var ix; @@ -45,10 +45,10 @@ function range( N, x, strideX, offsetX ) { var i; // Cache references to array data: - xbuf = x.data; + xbuf = obj.data; // Cache references to element accessors: - xget = x.accessors[ 0 ]; + xget = obj.accessors[ 0 ]; if ( N === 1 || strideX === 0 ) { v = xget( xbuf, offsetX ); From dca37eb4cf342d57e0d0a7e0f8a49341702384e8 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 18:43:09 +0530 Subject: [PATCH 10/20] done --- .../@stdlib/stats/base/range/docs/repl.txt | 55 ++++++++----------- .../@stdlib/stats/base/range/lib/accessors.js | 2 +- 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index 5df3e54b2dcb..ac2a7a4c0b71 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -1,9 +1,9 @@ -{{alias}}( N, x, strideX ) +{{alias}}( N, x, stride ) Computes the range of a strided array. - The `N` and stride parameters determine which elements in the strided - array are accessed at runtime. + The `N` and `stride` parameters determine which elements in `x` are + accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -15,11 +15,11 @@ N: integer Number of indexed elements. - x: Array | TypedArray + x: Array|TypedArray Input array. - strideX: integer - Stride length. + stride: integer + Index increment. Returns ------- @@ -33,30 +33,25 @@ > {{alias}}( x.length, x, 1 ) 4.0 - // Using `N` and stride parameters: + // Using `N` and `stride` parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; + > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); > var stride = 2; - > {{alias}}( 3, x, stride ) + > {{alias}}( N, x, stride ) 4.0 - // Handling `N <= 0` case: - > x = [ 1.0, -2.0, 2.0 ]; - > {{alias}}( 0, x, 1 ) - NaN - // Using view offsets: - > var x0 = new ({{alias:@stdlib/array/float64}}) + > var x0 = new {{alias:@stdlib/array/float64}} ( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); - > var x1 = new ({{alias:@stdlib/array/float64}}) - ( x0.buffer, x0.BYTES_PER_ELEMENT * 1 ); + > var x1 = new {{alias:@stdlib/array/float64}} + ( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); > stride = 2; - > {{alias}}( 3, x1, stride ) + > {{alias}}( N, x1, stride ) 4.0 - -{{alias}}.ndarray( N, x, strideX, offsetX ) - Computes the range of a strided array using alternative indexing - semantics. +{{alias}}.ndarray( N, x, stride, offset ) + Computes the range of a strided array 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 @@ -67,13 +62,13 @@ N: integer Number of indexed elements. - x: Array | TypedArray + x: Array|TypedArray Input array. - strideX: integer - Stride length. + stride: integer + Index increment. - offsetX: integer + offset: integer Starting index. Returns @@ -90,13 +85,9 @@ // Using offset parameter: > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; - > {{alias}}.ndarray( 3, x, 2, 1 ) + > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); + > {{alias}}.ndarray( N, x, 2, 1 ) 4.0 - // Handling `N <= 0` case: - > x = [ 1.0, -2.0, 2.0 ]; - > {{alias}}.ndarray( 0, x, 1, 0 ) - NaN - See Also - -------- + -------- \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js index 08bbb4475f81..d5b66403f8cf 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/range/lib/accessors.js @@ -38,9 +38,9 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); function range( N, obj, strideX, offsetX ) { var xbuf; var xget; - var ix; var min; var max; + var ix; var v; var i; From a9cc5fd91d27b3d606f30299eeb1f8afeff9aa5a Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 18:49:38 +0530 Subject: [PATCH 11/20] edit --- .../@stdlib/stats/base/range/docs/repl.txt | 31 ++++++++++--------- .../@stdlib/stats/base/range/lib/range.js | 1 + 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index ac2a7a4c0b71..abde753767aa 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -1,9 +1,9 @@ -{{alias}}( N, x, stride ) +{{alias}}( N, x, strideX ) Computes the range of a strided array. - The `N` and `stride` 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 a typed array view. @@ -18,8 +18,8 @@ x: Array|TypedArray Input array. - stride: integer - Index increment. + strideX: integer + Stride length. Returns ------- @@ -30,12 +30,12 @@ -------- // Standard Usage: > var x = [ 1.0, -2.0, 2.0 ]; - > {{alias}}( x.length, x, 1 ) + > {{alias}}( 3, x, 1 ) 4.0 - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); + > var N = {{alias:@stdlib/math/base/special/floor}}( 3 / 2 ); > var stride = 2; > {{alias}}( N, x, stride ) 4.0 @@ -50,7 +50,8 @@ > {{alias}}( N, x1, stride ) 4.0 -{{alias}}.ndarray( N, x, stride, offset ) + +{{alias}}.ndarray( N, x, strideX, offsetX ) Computes the range of a strided array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying @@ -65,10 +66,10 @@ x: Array|TypedArray Input array. - stride: integer - Index increment. + strideX: integer + Stride length. - offset: integer + offsetX: integer Starting index. Returns @@ -80,14 +81,14 @@ -------- // Standard Usage: > var x = [ 1.0, -2.0, 2.0 ]; - > {{alias}}.ndarray( x.length, x, 1, 0 ) + > {{alias}}.ndarray( 3, x, 1, 0 ) 4.0 // Using offset parameter: > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); + > var N = {{alias:@stdlib/math/base/special/floor}}( 3 / 2 ); > {{alias}}.ndarray( N, x, 2, 1 ) 4.0 See Also - -------- \ No newline at end of file + -------- diff --git a/lib/node_modules/@stdlib/stats/base/range/lib/range.js b/lib/node_modules/@stdlib/stats/base/range/lib/range.js index bcce468ecfe3..dc12a706b917 100644 --- a/lib/node_modules/@stdlib/stats/base/range/lib/range.js +++ b/lib/node_modules/@stdlib/stats/base/range/lib/range.js @@ -23,6 +23,7 @@ var stride2offset = require( '@stdlib/strided/base/stride2offset' ); var ndarray = require( './ndarray.js' ); + // MAIN // /** From 5bad41c788f13b54d9ff9198be06c77bd4733ceb Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 18:58:32 +0530 Subject: [PATCH 12/20] check --- lib/node_modules/@stdlib/stats/base/range/docs/repl.txt | 6 +++--- .../@stdlib/stats/base/range/test/test.ndarray.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index abde753767aa..b3b2f685a0d1 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -38,7 +38,7 @@ > var N = {{alias:@stdlib/math/base/special/floor}}( 3 / 2 ); > var stride = 2; > {{alias}}( N, x, stride ) - 4.0 + NaN // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}} @@ -48,7 +48,7 @@ > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); > stride = 2; > {{alias}}( N, x1, stride ) - 4.0 + NaN {{alias}}.ndarray( N, x, strideX, offsetX ) @@ -88,7 +88,7 @@ > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; > var N = {{alias:@stdlib/math/base/special/floor}}( 3 / 2 ); > {{alias}}.ndarray( N, x, 2, 1 ) - 4.0 + 0 See Also -------- diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js index 0f730efcce58..ef4cd0e8e939 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js @@ -20,10 +20,10 @@ // MODULES // -var tape = require('tape'); -var toAccessorArray = require('@stdlib/array/base/to-accessor-array'); -var isPositiveZero = require('@stdlib/math/base/assert/is-positive-zero'); -var range = require('./../lib/ndarray.js'); +var tape = require( 'tape' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var range = require( './../lib/ndarray.js' ); // TESTS // From 81e2b19d2dd1db4a2ae3e518ced14baedcb8f33d Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 19:04:29 +0530 Subject: [PATCH 13/20] repl --- lib/node_modules/@stdlib/stats/base/range/docs/repl.txt | 4 ++-- .../@stdlib/stats/base/range/test/test.range.js | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index b3b2f685a0d1..1e739d0217e9 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -38,7 +38,7 @@ > var N = {{alias:@stdlib/math/base/special/floor}}( 3 / 2 ); > var stride = 2; > {{alias}}( N, x, stride ) - NaN + 0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}} @@ -48,7 +48,7 @@ > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); > stride = 2; > {{alias}}( N, x1, stride ) - NaN + 0 {{alias}}.ndarray( N, x, strideX, offsetX ) diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js index a40240d4e5fd..623235b177c4 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js @@ -70,18 +70,17 @@ tape( 'the function calculates the range of a strided array', function test( t ) }); tape( 'the function calculates the range value of a sorted strided array (accessor)', function test( t ) { + var v = range( x.length, x, accessor, 1 ); + var x = toAccessorArray( new Float64Array( [ -5.0, -2.0, 0.0, 1.0, 3.0, 5.0 ] ) ); + function accessor( arr, idx ) { return arr.get( idx ); } - var x = toAccessorArray( new Float64Array( [ -5.0, -2.0, 0.0, 1.0, 3.0, 5.0 ] ) ); - var v = range( x.length, x, accessor, 1 ); - t.strictEqual(isnan(v), true, '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; @@ -190,7 +189,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -212,4 +210,3 @@ tape( 'the function supports view offsets', function test( t ) { t.end(); }); - From 73a5b995cb59091d7792953b4a7dda6382e6d3c8 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 19:05:25 +0530 Subject: [PATCH 14/20] check --- .../@stdlib/stats/base/range/test/test.range.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js index 623235b177c4..f8ec56267d36 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.range.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.range.js @@ -69,18 +69,6 @@ tape( 'the function calculates the range of a strided array', function test( t ) t.end(); }); -tape( 'the function calculates the range value of a sorted strided array (accessor)', function test( t ) { - var v = range( x.length, x, accessor, 1 ); - var x = toAccessorArray( new Float64Array( [ -5.0, -2.0, 0.0, 1.0, 3.0, 5.0 ] ) ); - - function accessor( arr, idx ) { - return arr.get( idx ); - } - - t.strictEqual(isnan(v), true, '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; From df60874c2c7871cadad6b183f01d5278801d43b9 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 19:09:50 +0530 Subject: [PATCH 15/20] lint --- .../@stdlib/stats/base/range/benchmark/benchmark.ndarray.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js index 3fcc163909c1..e97c037dd409 100644 --- a/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/benchmark/benchmark.ndarray.js @@ -38,7 +38,6 @@ var range = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; var x = discreteUniform(len, 0, len, { 'dtype': 'float64' }); From 3fe3a459656a5396f73cd00741db068ba2b951af Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 20:13:40 +0530 Subject: [PATCH 16/20] license --- .../stats/base/range/test/test.ndarray.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js index ef4cd0e8e939..cd990e2e16c0 100644 --- a/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/range/test/test.ndarray.js @@ -1,20 +1,20 @@ /** - * @license Apache-2.0 - * - * 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. - * 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. - */ +* @license Apache-2.0 +* +* 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. +* 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'; From ef9646e54b64dd87ace5076c249e763de3fa6f9b Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 22:27:52 +0530 Subject: [PATCH 17/20] check --- lib/node_modules/@stdlib/stats/base/range/docs/repl.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index 1e739d0217e9..4193f3aafa5b 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -38,7 +38,7 @@ > var N = {{alias:@stdlib/math/base/special/floor}}( 3 / 2 ); > var stride = 2; > {{alias}}( N, x, stride ) - 0 + 4.0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}} @@ -48,7 +48,7 @@ > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); > stride = 2; > {{alias}}( N, x1, stride ) - 0 + NaN {{alias}}.ndarray( N, x, strideX, offsetX ) From a4b6e5a80ea16262431fbc343e573cf02d4aac0b Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 22:32:09 +0530 Subject: [PATCH 18/20] repl --- lib/node_modules/@stdlib/stats/base/range/docs/repl.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index 4193f3aafa5b..76252f5ac180 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -38,13 +38,11 @@ > var N = {{alias:@stdlib/math/base/special/floor}}( 3 / 2 ); > var stride = 2; > {{alias}}( N, x, stride ) - 4.0 + 0 // Using view offsets: - > var x0 = new {{alias:@stdlib/array/float64}} - ( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); - > var x1 = new {{alias:@stdlib/array/float64}} - ( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.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 ); > stride = 2; > {{alias}}( N, x1, stride ) From 74aaf569bc24ec065076a74b11b09691a287578b Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 22:36:38 +0530 Subject: [PATCH 19/20] - --- lib/node_modules/@stdlib/stats/base/range/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index 76252f5ac180..c3b2cb4587fd 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -31,7 +31,7 @@ // Standard Usage: > var x = [ 1.0, -2.0, 2.0 ]; > {{alias}}( 3, x, 1 ) - 4.0 + NaN // Using `N` and stride parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; From 9d2bcd95778ad2d47b4a58727fac6337db9e5f29 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 22:41:59 +0530 Subject: [PATCH 20/20] done --- lib/node_modules/@stdlib/stats/base/range/docs/repl.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt index c3b2cb4587fd..97914010d7b1 100644 --- a/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/range/docs/repl.txt @@ -31,7 +31,7 @@ // Standard Usage: > var x = [ 1.0, -2.0, 2.0 ]; > {{alias}}( 3, x, 1 ) - NaN + 4.0 // Using `N` and stride parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; @@ -46,7 +46,7 @@ > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); > stride = 2; > {{alias}}( N, x1, stride ) - NaN + 4.0 {{alias}}.ndarray( N, x, strideX, offsetX )