From 3c9b304c6d183238f322b9ee84cf29d1967fff51 Mon Sep 17 00:00:00 2001 From: jsndz Date: Sat, 15 Mar 2025 15:35:42 +0530 Subject: [PATCH 01/28] refactor(stats/base/cuminabs): add accessor protocol support - Refactored cuminabs implementation to support accessor protocol. - Standardized descriptions and parameter documentation. - Updated examples and benchmarks to align with stdlib conventions. - Reduced code duplication by delegating main entry point to ndarray API. - Added explicit tests for accessor arrays. - Ensured compatibility with strided array dependencies. --- .../@stdlib/stats/base/cuminabs/README.md | 20 +- .../base/cuminabs/benchmark/benchmark.js | 31 +- .../cuminabs/benchmark/benchmark.ndarray.js | 30 +- .../@stdlib/stats/base/cuminabs/docs/repl.txt | 21 +- .../stats/base/cuminabs/docs/types/index.d.ts | 28 +- .../stats/base/cuminabs/docs/types/test.ts | 4 + .../stats/base/cuminabs/examples/index.js | 15 +- .../stats/base/cuminabs/lib/accessors.js | 116 +++++++ .../stats/base/cuminabs/lib/cuminabs.js | 56 +--- .../stats/base/cuminabs/lib/ndarray.js | 18 +- .../stats/base/cuminabs/test/test.cuminabs.js | 247 ++++++++++++++- .../stats/base/cuminabs/test/test.ndarray.js | 283 +++++++++++++++++- 12 files changed, 739 insertions(+), 130 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/README.md b/lib/node_modules/@stdlib/stats/base/cuminabs/README.md index b08a878e9167..6cde539e6c04 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/README.md +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/README.md @@ -52,11 +52,11 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. -- **strideX**: index increment for `x`. +- **strideX**: stride length for `x`. - **y**: output [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. -- **strideY**: index increment for `y`. +- **strideY**: stride length for `y`. -The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to compute the cumulative minimum absolute value of every other element in `x`, +The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative minimum absolute value 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 ]; @@ -102,7 +102,7 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetY**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, `offsetX` and `offsetY` parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative minimum absolute value of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative minimum absolute value of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element ```javascript var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; @@ -122,6 +122,7 @@ cuminabs.ndarray( 4, x, 2, 1, y, -1, y.length-1 ); - If `N <= 0`, both functions return `y` unchanged. - Depending on the environment, the typed versions ([`dcuminabs`][@stdlib/stats/strided/dcuminabs], [`scuminabs`][@stdlib/stats/base/scuminabs], 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]). @@ -134,11 +135,15 @@ cuminabs.ndarray( 4, x, 2, 1, y, -1, y.length-1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var cuminabs = require( '@stdlib/stats/base/cuminabs' ); +var x = discreteUniform( 10, 0, 100, { + 'dtype': 'float64' +}); +var y = new Float64Array( x.length ); + var y; var x; var i; @@ -188,8 +193,11 @@ console.log( y ); [mdn-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array +[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor + [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray + [@stdlib/stats/base/cumaxabs]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/cumaxabs diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.js index f68241a70716..08bc7b401e5f 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.js @@ -21,13 +21,22 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); +var gfill = require( '@stdlib/blas/ext/base/gfill' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; var cuminabs = require( './../lib/cuminabs.js' ); +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + // FUNCTIONS // /** @@ -38,35 +47,25 @@ var cuminabs = require( './../lib/cuminabs.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var y; - var x; - var i; - - x = []; - y = []; - for ( i = 0; i < len; i++ ) { - x.push( ( randu()*20.0 ) - 10.0 ); - y.push( 0.0 ); - } + var x = uniform( len, -10, 10, options ); + var y = zeros( len, options.dtype ); return benchmark; function benchmark( b ) { var v; var i; - for ( i = 0; i < len; i++ ) { - y[ i ] = 0.0; - } + gfill( len, 0.0, y, 1 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { x[ 0 ] += 1.0; v = cuminabs( x.length, x, 1, y, 1 ); - if ( isnan( v[ i%len ] ) ) { + if ( isnan( v[ i % len ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( v[ i%len ] ) ) { + if ( isnan( v[ i % len ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.ndarray.js index af00fc89932e..4c5416ed15dd 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.ndarray.js @@ -21,13 +21,21 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); +var gfill = require( '@stdlib/blas/ext/base/gfill' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; var cuminabs = require( './../lib/ndarray.js' ); +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + // FUNCTIONS // /** @@ -38,35 +46,25 @@ var cuminabs = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = []; - y = []; - for ( i = 0; i < len; i++ ) { - x.push( ( randu()*20.0 ) - 10.0 ); - y.push( 0.0 ); - } + var x = uniform( len, -10, 10, options ); + var y = zeros( len, options.dtype ); return benchmark; function benchmark( b ) { var v; var i; - for ( i = 0; i < len; i++ ) { - y[ i ] = 0.0; - } + gfill( len, 0.0, y, 1 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { x[ 0 ] += 1.0; v = cuminabs( x.length, x, 1, 0, y, 1, 0 ); - if ( isnan( v[ i%len ] ) ) { + if ( isnan( v[ i % len ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( v[ i%len ] ) ) { + if ( isnan( v[ i % len ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/cuminabs/docs/repl.txt index 8881fca3325e..08f91228a4b4 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/docs/repl.txt @@ -2,7 +2,7 @@ {{alias}}( N, x, strideX, y, strideY ) Computes the cumulative minimum absolute value of a strided array. - The `N` and `stride` parameters determine which elements in `x` and `y` are + The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed @@ -19,13 +19,13 @@ Input array. strideX: integer - Index increment for `x`. + Stride length for `x`. y: Array|TypedArray Output array. strideY: integer - Index increment for `y`. + Stride length for `y`. Returns ------- @@ -40,11 +40,10 @@ > {{alias}}( x.length, x, 1, y, 1 ) [ 1.0, 1.0, 1.0 ] - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; > y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, x, 2, y, 2 ) + > {{alias}}( 3, x, 2, y, 2 ) [ 2.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] // Using view offsets: @@ -52,8 +51,7 @@ > var y0 = new {{alias:@stdlib/array/float64}}( x0.length ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > {{alias}}( N, x1, 2, y1, 1 ) + > {{alias}}( 3, x1, 2, y1, 1 ) [ 2.0, 2.0, 1.0 ] > y0 [ 0.0, 0.0, 0.0, 2.0, 2.0, 1.0 ] @@ -75,7 +73,7 @@ Input array. strideX: integer - Index increment for `x`. + Stride length for `x`. offsetX: integer Starting index for `x`. @@ -84,7 +82,7 @@ Output array. strideY: integer - Index increment for `y`. + Stride length for `y`. offsetY: integer Starting index for `y`. @@ -105,8 +103,7 @@ // Advanced indexing: > x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; > y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1, y, -1, y.length-1 ) + > {{alias}}.ndarray( 3, x, 2, 1, y, -1, y.length-1 ) [ 0.0, 0.0, 0.0, 1.0, 2.0, 2.0 ] See Also diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/index.d.ts index efef24911f98..becc70e98334 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/index.d.ts @@ -20,7 +20,17 @@ /// -import { NumericArray } from '@stdlib/types/array'; +import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; + +/** +* Input array. +*/ +type InputArray = NumericArray | Collection | AccessorArrayLike; + +/** +* Output array. +*/ +type OutputArray = NumericArray | Collection | AccessorArrayLike; /** * Interface describing `cuminabs`. @@ -31,9 +41,9 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array - * @param strideX - `x` stride length + * @param strideX - stride length for `x` * @param y - output array - * @param strideY - `y` stride length + * @param strideY - stride length for `y` * @returns output array * * @example @@ -43,17 +53,17 @@ interface Routine { * cuminabs( x.length, x, 1, y, 1 ); * // y => [ 1.0, 1.0, 1.0 ] */ - ( N: number, x: NumericArray, strideX: number, y: NumericArray, strideY: number ): NumericArray; + ( N: number, x: InputArray, strideX: number, y: T, strideY: number ): T; /** * Computes the cumulative minimum absolute value of a strided array using alternative indexing semantics. * * @param N - number of indexed elements * @param x - input array - * @param strideX - `x` stride length + * @param strideX - stride length for `x` * @param offsetX - starting index for `x` * @param y - output array - * @param strideY - `y` stride length + * @param strideY - stride length for `y` * @param offsetY - starting index for `y` * @returns output array * @@ -64,7 +74,7 @@ interface Routine { * cuminabs.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // y => [ 1.0, 1.0, 1.0 ] */ - ndarray( N: number, x: NumericArray, strideX: number, offsetX: number, y: NumericArray, strideY: number, offsetY: number ): NumericArray; + ndarray( N: number, x: InputArray, strideX: number, offsetX: number, y: T, strideY: number, offsetY: number ): T; } /** @@ -72,9 +82,9 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array -* @param strideX - `x` stride length +* @param strideX - stride length for `x` * @param y - output array -* @param strideY - `y` stride length +* @param strideY - stride length for `y` * @returns output array * * @example diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/test.ts index 6b6d7af70bf7..bc7d86e1705e 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import AccessorArray = require( '@stdlib/array/base/accessor' ); import cuminabs = require( './index' ); @@ -27,6 +28,7 @@ import cuminabs = require( './index' ); const y = new Float64Array( 10 ); cuminabs( x.length, x, 1, y, 1 ); // $ExpectType NumericArray + cuminabs( x.length, new AccessorArray( x ), 1, new AccessorArray( y ), 1 ); // $ExpectType AccessorArray } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -124,6 +126,8 @@ import cuminabs = require( './index' ); const y = new Float64Array( 10 ); cuminabs.ndarray( x.length, x, 1, 0, y, 1, 0 ); // $ExpectType NumericArray + cuminabs.ndarray( x.length, new AccessorArray( x ), 1, 0, new AccessorArray( y ), 1, 0 ); // $ExpectType AccessorArray + } // 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/cuminabs/examples/index.js b/lib/node_modules/@stdlib/stats/base/cuminabs/examples/index.js index 90ddc21deb45..5a33392f53c1 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/examples/index.js @@ -18,20 +18,15 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var Float64Array = require( '@stdlib/array/float64' ); var cuminabs = require( './../lib' ); -var y; -var x; -var i; +var x = discreteUniform(10, -50, 50, { + 'dtype': 'float64' +}); +var y = new Float64Array( x.length ); -x = new Float64Array( 10 ); -y = new Float64Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); -} console.log( x ); console.log( y ); diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js new file mode 100644 index 000000000000..6361ffae7fe4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var abs = require( '@stdlib/math/base/special/abs' ); + +// MAIN // + +/** +* Computes the cumulative minimum of a strided array. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {Object} x - input array object +* @param {Collection} x.data - input array data +* @param {Array} x.accessors - array element accessors +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Object} y - output array object +* @param {Collection} y.data - output array data +* @param {Array} y.accessors - array element accessors +* @param {integer} strideY - stride length for `y` +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @returns {Object} output array object +* +* @example +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var accessors = require( './accessors.js' ); +* +* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; +* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* var v = cuminabs( 4, arraylike2object( toAccessorArray( x ) ), 2, 1, arraylike2object( toAccessorArray( y ) ), 1, 0 ); +* // returns [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] +*/ + +function cuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) { + var xbuf; + var ybuf; + var xget; + var yset; + var min; + var ix; + var iy; + var v; + var i; + + // Cache references to array data: + xbuf = x.data; + ybuf = y.data; + + // Cache references to element accessors: + xget = x.accessors[0]; + yset = y.accessors[1]; + + + + ix = offsetX; + + iy = offsetY; + + min = abs(xget(xbuf, ix)); + + yset(ybuf, iy, min); + + iy += strideY; + + i = 1; + + if ( isnan( min ) === false ) { + for ( i; i < N; i++ ) { + ix += strideX; + v = abs(xget( xbuf, ix) ); + if ( isnan( v ) ) { + min = v; + break; + } + if ( v < min ) { + min = v; + } + yset(ybuf, iy, min); + iy += strideY; + } + } + if ( isnan( min ) ) { + for ( i; i < N; i++ ) { + yset(ybuf, iy, min); + iy += strideY; + } + } + return y; +} + + +// EXPORTS // + +module.exports = cuminabs; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/cuminabs.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/cuminabs.js index 9b6dffe2ddf3..9231b8cefcec 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/cuminabs.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/cuminabs.js @@ -20,9 +20,8 @@ // MODULES // -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); - +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray' ); // MAIN // @@ -45,52 +44,11 @@ var abs = require( '@stdlib/math/base/special/abs' ); * // returns [ 1.0, 1.0, 1.0 ] */ function cuminabs( N, x, strideX, y, strideY ) { - var min; - var ix; - var iy; - var v; - var i; - - if ( N <= 0 ) { - return y; - } - if ( strideX < 0 ) { - ix = (1-N) * strideX; - } else { - ix = 0; - } - if ( strideY < 0 ) { - iy = (1-N) * strideY; - } else { - iy = 0; - } - min = abs( x[ ix ] ); - y[ iy ] = min; - - iy += strideY; - i = 1; - if ( isnan( min ) === false ) { - for ( i; i < N; i++ ) { - ix += strideX; - v = abs( x[ ix ] ); - if ( isnan( v ) ) { - min = v; - break; - } - if ( v < min ) { - min = v; - } - y[ iy ] = min; - iy += strideY; - } - } - if ( isnan( min ) ) { - for ( i; i < N; i++ ) { - y[ iy ] = min; - iy += strideY; - } - } - return y; + + var ix = stride2offset( N, strideX ); + var iy = stride2offset( N, strideY ); + + return ndarray( N, x, strideX, ix, y, strideY, iy ); } diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js index 73ed1d9c851a..0fa960cde48d 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js @@ -22,7 +22,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var abs = require( '@stdlib/math/base/special/abs' ); - +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var accessors = require( './accessors.js' ); // MAIN // @@ -31,10 +32,10 @@ var abs = require( '@stdlib/math/base/special/abs' ); * * @param {PositiveInteger} N - number of indexed elements * @param {NumericArray} x - input array -* @param {integer} strideX - `x` stride length +* @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` * @param {NumericArray} y - output array -* @param {integer} strideY - `y` stride length +* @param {integer} strideY - stride length for `y` * @param {NonNegativeInteger} offsetY - starting index for `y` * @returns {NumericArray} output array * @@ -43,21 +44,28 @@ var abs = require( '@stdlib/math/base/special/abs' ); * * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; * var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; -* var N = floor( x.length / 2 ); * -* var v = cuminabs( N, x, 2, 1, y, 1, 0 ); +* var v = cuminabs( 4, x, 2, 1, y, 1, 0 ); * // returns [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] */ function cuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) { var min; var ix; var iy; + var ox; + var oy; var v; var i; if ( N <= 0 ) { return y; } + ox = arraylike2object( x ); + oy = arraylike2object( y ); + if ( ox.accessorProtocol || oy.accessorProtocol ) { + accessors( N, ox, strideX, offsetX, oy, strideY, offsetY ); + return y; + } ix = offsetX; iy = offsetY; diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js index 3b8d9983fc41..29afc9031a8d 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js @@ -21,9 +21,9 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var Float64Array = require( '@stdlib/array/float64' ); var cuminabs = require( './../lib/cuminabs.js' ); @@ -109,6 +109,74 @@ tape( 'the function computes the cumulative minimum absolute value', function te t.end(); }); +tape( 'the function computes the cumulative minimum absolute value (accessor)', function test( t ) { + var expected; + var x; + var y; + var i; + + x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ]; + y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; + cuminabs( x.length, toAccessorArray( x ), 1, toAccessorArray( y ), 1 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0 + ]; + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ -0.0, 0.0, -0.0 ]; + y = [ -0.0, -0.0, -0.0 ]; + cuminabs( x.length, toAccessorArray( x ), 1, toAccessorArray( y ), 1 ); + + expected = [ + 0.0, + 0.0, + 0.0 + ]; + for ( i = 0; i < y.length; i++ ) { + t.strictEqual( isPositiveZero( y[ i ] ), true, 'returns expected value. i: ' + i ); + } + + x = [ NaN ]; + y = [ 0.0 ]; + cuminabs( x.length, toAccessorArray( x ), 1, toAccessorArray( y ), 1 ); + + for ( i = 0; i < y.length; i++ ) { + t.strictEqual( isnan( y[ i ] ), true, 'returns expected value. i: ' + i ); + } + + x = [ NaN, NaN ]; + y = [ 0.0, 0.0 ]; + cuminabs( x.length, toAccessorArray( x ), 1, toAccessorArray( y ), 1 ); + + for ( i = 0; i < y.length; i++ ) { + t.strictEqual( isnan( y[ i ] ), true, 'returns expected value. i: ' + i ); + } + + x = [ 1.0, NaN, 3.0, NaN ]; + y = [ 0.0, 0.0, 0.0, 0.0 ]; + cuminabs( x.length, toAccessorArray( x ), 1, toAccessorArray( y ), 1 ); + + expected = [ + 1.0, + NaN, + NaN, + NaN + ]; + for ( i = 0; i < y.length; i++ ) { + if ( isnan( expected[ i ] ) ) { + t.strictEqual( isnan( y[ i ] ), true, 'returns expected value. i: ' + i ); + } else { + t.strictEqual( y[ i ], expected[ i ], true, 'returns expected value. i: ' + i ); + } + } + t.end(); +}); + tape( 'the function returns a reference to the output array', function test( t ) { var out; var x; @@ -123,6 +191,20 @@ tape( 'the function returns a reference to the output array', function test( t ) t.end(); }); +tape( 'the function returns a reference to the output array (accessor)', function test( t ) { + var out; + var x; + var y; + + x = toAccessorArray([ 1.0, 2.0, 3.0, 4.0, 5.0 ]); + y = toAccessorArray([ 0.0, 0.0, 0.0, 0.0, 0.0 ]); + + out = cuminabs( x.length, x, 1, y, 1 ); + t.strictEqual( out, y, 'same reference' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) { var expected; var x; @@ -172,6 +254,36 @@ tape( 'the function supports an `x` stride', function test( t ) { t.end(); }); +tape( 'the function supports an `x` stride (accessor)', function test( t ) { + var expected; + var x; + var y; + var N; + + x = [ + 1.0, // 0 + -2.0, + 3.0, // 1 + 4.0, + -5.0 // 2 + ]; + y = [ + 0.0, // 0 + 0.0, // 1 + 0.0, // 2 + 0.0, + 0.0 + ]; + N = 3; + + cuminabs( N, toAccessorArray( x ), 2, toAccessorArray( y ), 1 ); + + expected = [ 1.0, 1.0, 1.0, 0.0, 0.0 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports a `y` stride', function test( t ) { var expected; var x; @@ -202,6 +314,36 @@ tape( 'the function supports a `y` stride', function test( t ) { t.end(); }); +tape( 'the function supports a `y` stride (accessor)', function test( t ) { + var expected; + var x; + var y; + var N; + + x = [ + 1.0, // 0 + -2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]; + y = [ + 0.0, // 0 + 0.0, + 0.0, // 1 + 0.0, + 0.0 // 2 + ]; + N = 3; + + cuminabs( N, toAccessorArray( x ), 1, toAccessorArray( y ), 2 ); + + expected = [ 1.0, 0.0, 1.0, 0.0, 1.0 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports negative strides', function test( t ) { var expected; var x; @@ -232,6 +374,36 @@ tape( 'the function supports negative strides', function test( t ) { t.end(); }); +tape( 'the function supports negative strides (accessor)', function test( t ) { + var expected; + var x; + var y; + var N; + + x = [ + 1.0, // 2 + -2.0, + 3.0, // 1 + 4.0, + -5.0 // 0 + ]; + y = [ + 0.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0 + ]; + N = 3; + + cuminabs( N, toAccessorArray( x ), -2, toAccessorArray( y ), -1 ); + + expected = [ 1.0, 3.0, 5.0, 0.0, 0.0 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports complex access patterns', function test( t ) { var expected; var x; @@ -264,6 +436,38 @@ tape( 'the function supports complex access patterns', function test( t ) { t.end(); }); +tape( 'the function supports complex access patterns (accessor)', function test( t ) { + var expected; + var x; + var y; + var N; + + x = [ + 1.0, // 0 + 2.0, + -3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 0.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0, + 0.0 + ]; + N = 3; + + cuminabs( N, toAccessorArray( x ), 2, toAccessorArray( y ), -1 ); + + expected = [ 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var expected; var x0; @@ -294,11 +498,46 @@ tape( 'the function supports view offsets', function test( t ) { x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); - - cuminabs( N, x1, -2, y1, 1 ); + cuminabs( 3, x1, -2, y1, 1 ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 6.0, 4.0, 2.0 ] ); t.deepEqual( y0, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function supports view offsets (accessor)', function test( t ) { + var expected; + var x0; + var y0; + var x1; + var y1; + var N; + + // Initial arrays... + x0 = new Float64Array([ + 1.0, + 2.0, // 2 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 0 + ]); + y0 = new Float64Array([ + 0.0, + 0.0, + 0.0, + 0.0, // 0 + 0.0, // 1 + 0.0 // 2 + ]); + + // Create offset views... + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element + + cuminabs( 3, toAccessorArray( x1 ), -2, toAccessorArray( y1 ), 1 ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 6.0, 4.0, 2.0 ] ); + + t.deepEqual( y0, expected, 'returns expected value' ); + t.end(); +}); \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js index 188e85d243a7..7192fb07a18b 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.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 cuminabs = require( './../lib/ndarray.js' ); @@ -108,6 +108,74 @@ tape( 'the function calculates the cumulative minimum absolute value', function t.end(); }); +tape( 'the function calculates the cumulative minimum absolute value (accessor)', function test( t ) { + var expected; + var x; + var y; + var i; + + x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ]; + y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; + cuminabs( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0 + ]; + t.deepEqual( y, expected, 'returns expected value' ); + + x = [ -0.0, 0.0, -0.0 ]; + y = [ -0.0, -0.0, -0.0 ]; + cuminabs( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + + expected = [ + 0.0, + 0.0, + 0.0 + ]; + for ( i = 0; i < y.length; i++ ) { + t.strictEqual( isPositiveZero( y[ i ] ), true, 'returns expected value. i: ' + i ); + } + + x = [ NaN ]; + y = [ 0.0 ]; + cuminabs( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + + for ( i = 0; i < y.length; i++ ) { + t.strictEqual( isnan( y[ i ] ), true, 'returns expected value. i: ' + i ); + } + + x = [ NaN, NaN ]; + y = [ 0.0, 0.0 ]; + cuminabs( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + + for ( i = 0; i < y.length; i++ ) { + t.strictEqual( isnan( y[ i ] ), true, 'returns expected value. i: ' + i ); + } + + x = [ 1.0, NaN, 3.0, NaN ]; + y = [ 0.0, 0.0, 0.0, 0.0 ]; + cuminabs( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + + expected = [ + 1.0, + NaN, + NaN, + NaN + ]; + for ( i = 0; i < y.length; i++ ) { + if ( isnan( expected[ i ] ) ) { + t.strictEqual( isnan( y[ i ] ), true, 'returns expected value. i: ' + i ); + } else { + t.strictEqual( y[ i ], expected[ i ], true, 'returns expected value. i: ' + i ); + } + } + t.end(); +}); + tape( 'the function returns a reference to the output array', function test( t ) { var out; var x; @@ -122,6 +190,20 @@ tape( 'the function returns a reference to the output array', function test( t ) t.end(); }); +tape( 'the function returns a reference to the output array (accessor)', function test( t ) { + var out; + var x; + var y; + + x = toAccessorArray([ 1.0, 2.0, 3.0, 4.0, 5.0 ]); + y = toAccessorArray([ 0.0, 0.0, 0.0, 0.0, 0.0 ]); + + out = cuminabs( x.length, x, 1, 0, y, 1, 0 ); + t.strictEqual( out, y, 'same reference' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) { var expected; var x; @@ -171,6 +253,36 @@ tape( 'the function supports an `x` stride', function test( t ) { t.end(); }); +tape( 'the function supports an `x` stride (accessor)', function test( t ) { + var expected; + var x; + var y; + var N; + + x = [ + 1.0, // 0 + -2.0, + 3.0, // 1 + 4.0, + -5.0 // 2 + ]; + y = [ + 0.0, // 0 + 0.0, // 1 + 0.0, // 2 + 0.0, + 0.0 + ]; + N = 3; + + cuminabs( N, toAccessorArray( x ), 2, 0, toAccessorArray( y ), 1, 0 ); + + expected = [ 1.0, 1.0, 1.0, 0.0, 0.0 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports a `y` stride', function test( t ) { var expected; var x; @@ -201,6 +313,36 @@ tape( 'the function supports a `y` stride', function test( t ) { t.end(); }); +tape( 'the function supports a `y` stride (accessor)', function test( t ) { + var expected; + var x; + var y; + var N; + + x = [ + 1.0, // 0 + -2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]; + y = [ + 0.0, // 0 + 0.0, + 0.0, // 1 + 0.0, + 0.0 // 2 + ]; + N = 3; + + cuminabs( N, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 2, 0 ); + + expected = [ 1.0, 0.0, 1.0, 0.0, 1.0 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports negative strides', function test( t ) { var expected; var x; @@ -231,6 +373,36 @@ tape( 'the function supports negative strides', function test( t ) { t.end(); }); +tape( 'the function supports negative strides (accessor)', function test( t ) { + var expected; + var x; + var y; + var N; + + x = [ + 1.0, // 2 + -2.0, + 3.0, // 1 + 4.0, + -5.0 // 0 + ]; + y = [ + 0.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0 + ]; + N = 3; + + cuminabs( N, toAccessorArray( x ), -2, x.length-1, toAccessorArray( y ), -1, 2 ); + + expected = [ 1.0, 3.0, 5.0, 0.0, 0.0 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports an `x` offset', function test( t ) { var expected; var N; @@ -257,7 +429,7 @@ tape( 'the function supports an `x` offset', function test( t ) { 0.0, 0.0 ]; - N = floor( x.length / 2 ); + N = 4; cuminabs( N, x, 2, 1, y, 1, 0 ); @@ -267,6 +439,42 @@ tape( 'the function supports an `x` offset', function test( t ) { t.end(); }); +tape( 'the function supports an `x` offset (accessor)', function test( t ) { + var expected; + var N; + var x; + var y; + + x = [ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0 // 3 + ]; + y = [ + 0.0, // 0 + 0.0, // 1 + 0.0, // 2 + 0.0, // 3 + 0.0, + 0.0, + 0.0, + 0.0 + ]; + N = 4; + + cuminabs( N, toAccessorArray( x ), 2, 1, toAccessorArray( y ), 1, 0 ); + + expected = [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports a `y` offset', function test( t ) { var expected; var N; @@ -293,7 +501,7 @@ tape( 'the function supports a `y` offset', function test( t ) { 0.0, 0.0 // 3 ]; - N = floor( x.length / 2 ); + N = 4; cuminabs( N, x, 1, 0, y, 2, 1 ); @@ -303,6 +511,42 @@ tape( 'the function supports a `y` offset', function test( t ) { t.end(); }); +tape( 'the function supports a `y` offset (accessor)', function test( t ) { + var expected; + var N; + var x; + var y; + + x = [ + 2.0, // 0 + 1.0, // 1 + 2.0, // 2 + -2.0, // 3 + -2.0, + 2.0, + 3.0, + 4.0 + ]; + y = [ + 0.0, + 0.0, // 0 + 0.0, + 0.0, // 1 + 0.0, + 0.0, // 2 + 0.0, + 0.0 // 3 + ]; + N = 4; + + cuminabs( N, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 2, 1 ); + + expected = [ 0.0, 2.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports complex access patterns', function test( t ) { var expected; var x; @@ -334,3 +578,36 @@ tape( 'the function supports complex access patterns', function test( t ) { t.end(); }); + + +tape( 'the function supports complex access patterns (accessor', function test( t ) { + var expected; + var x; + var y; + var N; + + x = [ + 1.0, // 0 + 2.0, + -3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]; + y = [ + 0.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0, + 0.0 + ]; + N = 3; + + cuminabs( N, toAccessorArray( x ), 2, 0, toAccessorArray( y ), -1, 2 ); + + expected = [ 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 ]; + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); \ No newline at end of file From 7e7602eee942ec8ba6f72c2e1d10d76066ff5ef0 Mon Sep 17 00:00:00 2001 From: jsndz Date: Sat, 15 Mar 2025 16:22:26 +0530 Subject: [PATCH 02/28] fixup! refactor(stats/base/cuminabs): Fixed README example --- lib/node_modules/@stdlib/stats/base/cuminabs/README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/README.md b/lib/node_modules/@stdlib/stats/base/cuminabs/README.md index 6cde539e6c04..ff553941509b 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/README.md +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/README.md @@ -135,7 +135,6 @@ cuminabs.ndarray( 4, x, 2, 1, y, -1, y.length-1 ); ```javascript -var Float64Array = require( '@stdlib/array/float64' ); var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var cuminabs = require( '@stdlib/stats/base/cuminabs' ); @@ -144,15 +143,6 @@ var x = discreteUniform( 10, 0, 100, { }); var y = new Float64Array( x.length ); -var y; -var x; -var i; - -x = new Float64Array( 10 ); -y = new Float64Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} console.log( x ); console.log( y ); From 044a99cc0cd14910947a914b72e5612c392395ac Mon Sep 17 00:00:00 2001 From: jsndz Date: Sat, 15 Mar 2025 23:47:18 +0530 Subject: [PATCH 03/28] fixup! refactor(stats/base/cuminabs): Fixed lint error --- .../stats/base/cuminabs/lib/accessors.js | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js index 6361ffae7fe4..5334d5e94878 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js @@ -43,8 +43,8 @@ var abs = require( '@stdlib/math/base/special/abs' ); * @returns {Object} output array object * * @example -var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -var accessors = require( './accessors.js' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* var accessors = require( './accessors.js' ); * * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; * var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; @@ -72,24 +72,18 @@ function cuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) { xget = x.accessors[0]; yset = y.accessors[1]; - - ix = offsetX; - iy = offsetY; - min = abs(xget(xbuf, ix)); - - yset(ybuf, iy, min); + min = abs( xget( xbuf, ix )); + yset( ybuf, iy, min ); iy += strideY; - i = 1; - if ( isnan( min ) === false ) { for ( i; i < N; i++ ) { ix += strideX; - v = abs(xget( xbuf, ix) ); + v = abs( xget( xbuf, ix ) ); if ( isnan( v ) ) { min = v; break; @@ -97,13 +91,13 @@ function cuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) { if ( v < min ) { min = v; } - yset(ybuf, iy, min); + yset( ybuf, iy, min ); iy += strideY; } } if ( isnan( min ) ) { for ( i; i < N; i++ ) { - yset(ybuf, iy, min); + yset( ybuf, iy, min ); iy += strideY; } } From f385c11993f4e60280e96e901a60ad6e2964223a Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 00:28:54 +0530 Subject: [PATCH 04/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 2 --- .../@stdlib/stats/base/cuminabs/lib/accessors.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js index 5334d5e94878..4374516315ce 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js @@ -52,7 +52,6 @@ var abs = require( '@stdlib/math/base/special/abs' ); * var v = cuminabs( 4, arraylike2object( toAccessorArray( x ) ), 2, 1, arraylike2object( toAccessorArray( y ) ), 1, 0 ); * // returns [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] */ - function cuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) { var xbuf; var ybuf; @@ -71,13 +70,13 @@ function cuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) { // Cache references to element accessors: xget = x.accessors[0]; yset = y.accessors[1]; - + ix = offsetX; iy = offsetY; - + min = abs( xget( xbuf, ix )); yset( ybuf, iy, min ); - + iy += strideY; i = 1; if ( isnan( min ) === false ) { @@ -107,4 +106,4 @@ function cuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) { // EXPORTS // -module.exports = cuminabs; \ No newline at end of file +module.exports = cuminabs; From 931d23bfddd62eb41dcd761cdeb677cc4fec795c Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 00:49:18 +0530 Subject: [PATCH 05/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 3 --- lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js index 4374516315ce..dbb47b3580fd 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js @@ -23,6 +23,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var abs = require( '@stdlib/math/base/special/abs' ); + // MAIN // /** @@ -43,6 +44,7 @@ var abs = require( '@stdlib/math/base/special/abs' ); * @returns {Object} output array object * * @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); * var accessors = require( './accessors.js' ); * From f16941b08d1640694bf6a02992ac79e1aed39024 Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 00:55:34 +0530 Subject: [PATCH 06/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 4 --- lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js index dbb47b3580fd..36633bd06c1b 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js @@ -52,7 +52,7 @@ var abs = require( '@stdlib/math/base/special/abs' ); * var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; * * var v = cuminabs( 4, arraylike2object( toAccessorArray( x ) ), 2, 1, arraylike2object( toAccessorArray( y ) ), 1, 0 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] +* // y => [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] */ function cuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) { var xbuf; From 98c9d1275b02af2b72591b3ec92db9b98ca507b6 Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 01:38:46 +0530 Subject: [PATCH 07/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 5 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/cuminabs/lib/cuminabs.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/cuminabs.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/cuminabs.js index 9231b8cefcec..6d5cc7cbb0dc 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/cuminabs.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/cuminabs.js @@ -21,7 +21,8 @@ // MODULES // var stride2offset = require( '@stdlib/strided/base/stride2offset' ); -var ndarray = require( './ndarray' ); +var ndarray = require( './ndarray.js' ); + // MAIN // @@ -44,10 +45,9 @@ var ndarray = require( './ndarray' ); * // returns [ 1.0, 1.0, 1.0 ] */ function cuminabs( N, x, strideX, y, strideY ) { - var ix = stride2offset( N, strideX ); var iy = stride2offset( N, strideY ); - + return ndarray( N, x, strideX, ix, y, strideY, iy ); } From c89beec37b0aa117e470606ad32f6055074f13c3 Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 11:18:52 +0530 Subject: [PATCH 08/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 6 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js | 1 + .../@stdlib/stats/base/cuminabs/test/test.cuminabs.js | 4 +--- .../@stdlib/stats/base/cuminabs/test/test.ndarray.js | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js index 0fa960cde48d..3ac39869b76e 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js @@ -25,6 +25,7 @@ var abs = require( '@stdlib/math/base/special/abs' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); var accessors = require( './accessors.js' ); + // MAIN // /** diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js index 29afc9031a8d..59a454b4938a 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js @@ -474,7 +474,6 @@ tape( 'the function supports view offsets', function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float64Array([ @@ -511,7 +510,6 @@ tape( 'the function supports view offsets (accessor)', function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float64Array([ @@ -540,4 +538,4 @@ tape( 'the function supports view offsets (accessor)', function test( t ) { t.deepEqual( y0, expected, 'returns expected value' ); t.end(); -}); \ No newline at end of file +}); diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js index 7192fb07a18b..7d6d1e980351 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js @@ -579,7 +579,6 @@ tape( 'the function supports complex access patterns', function test( t ) { t.end(); }); - tape( 'the function supports complex access patterns (accessor', function test( t ) { var expected; var x; @@ -610,4 +609,4 @@ tape( 'the function supports complex access patterns (accessor', function test( t.deepEqual( y, expected, 'returns expected value' ); t.end(); -}); \ No newline at end of file +}); From 78ad06aef24fb611b7b3faf5864aa249c61ca31a Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 11:32:57 +0530 Subject: [PATCH 09/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 6 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/cuminabs/examples/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/examples/index.js b/lib/node_modules/@stdlib/stats/base/cuminabs/examples/index.js index 5a33392f53c1..aee1bc8caad9 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/examples/index.js @@ -22,9 +22,9 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var Float64Array = require( '@stdlib/array/float64' ); var cuminabs = require( './../lib' ); -var x = discreteUniform(10, -50, 50, { - 'dtype': 'float64' -}); +var x = discreteUniform(10, -50, 50, { + 'dtype': 'float64' +}); var y = new Float64Array( x.length ); console.log( x ); From a6e8902319380cf96c0f1622ed55584581913490 Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 11:53:34 +0530 Subject: [PATCH 10/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 7 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/cuminabs/benchmark/benchmark.ndarray.js | 1 + .../stats/base/cuminabs/test/test.ndarray.js | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.ndarray.js index 4c5416ed15dd..d9ece97cfd1a 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/benchmark/benchmark.ndarray.js @@ -36,6 +36,7 @@ var options = { 'dtype': 'generic' }; + // FUNCTIONS // /** diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js index 7d6d1e980351..2f9cc3f19bcf 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js @@ -116,7 +116,7 @@ tape( 'the function calculates the cumulative minimum absolute value (accessor)' x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ]; y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; - cuminabs( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + cuminabs(x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0); expected = [ 1.0, @@ -129,7 +129,7 @@ tape( 'the function calculates the cumulative minimum absolute value (accessor)' x = [ -0.0, 0.0, -0.0 ]; y = [ -0.0, -0.0, -0.0 ]; - cuminabs( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + cuminabs(x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0); expected = [ 0.0, @@ -142,7 +142,7 @@ tape( 'the function calculates the cumulative minimum absolute value (accessor)' x = [ NaN ]; y = [ 0.0 ]; - cuminabs( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + cuminabs(x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0); for ( i = 0; i < y.length; i++ ) { t.strictEqual( isnan( y[ i ] ), true, 'returns expected value. i: ' + i ); @@ -150,7 +150,7 @@ tape( 'the function calculates the cumulative minimum absolute value (accessor)' x = [ NaN, NaN ]; y = [ 0.0, 0.0 ]; - cuminabs( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + cuminabs(x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0); for ( i = 0; i < y.length; i++ ) { t.strictEqual( isnan( y[ i ] ), true, 'returns expected value. i: ' + i ); @@ -158,7 +158,7 @@ tape( 'the function calculates the cumulative minimum absolute value (accessor)' x = [ 1.0, NaN, 3.0, NaN ]; y = [ 0.0, 0.0, 0.0, 0.0 ]; - cuminabs( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); + cuminabs(x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0); expected = [ 1.0, @@ -275,7 +275,7 @@ tape( 'the function supports an `x` stride (accessor)', function test( t ) { ]; N = 3; - cuminabs( N, toAccessorArray( x ), 2, 0, toAccessorArray( y ), 1, 0 ); + cuminabs(N, toAccessorArray( x ), 2, 0, toAccessorArray( y ), 1, 0); expected = [ 1.0, 1.0, 1.0, 0.0, 0.0 ]; t.deepEqual( y, expected, 'returns expected value' ); @@ -395,7 +395,7 @@ tape( 'the function supports negative strides (accessor)', function test( t ) { ]; N = 3; - cuminabs( N, toAccessorArray( x ), -2, x.length-1, toAccessorArray( y ), -1, 2 ); + cuminabs( N, toAccessorArray( x ), -2, x.length-1, toAccessorArray( y ), -1, 2); expected = [ 1.0, 3.0, 5.0, 0.0, 0.0 ]; t.deepEqual( y, expected, 'returns expected value' ); From 8b0cfd537598938bb0af8e539fd4f58b29be8d3a Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 11:55:36 +0530 Subject: [PATCH 11/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 7 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/cuminabs/test/test.ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js index 2f9cc3f19bcf..0dc1c206d05c 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js @@ -395,7 +395,7 @@ tape( 'the function supports negative strides (accessor)', function test( t ) { ]; N = 3; - cuminabs( N, toAccessorArray( x ), -2, x.length-1, toAccessorArray( y ), -1, 2); + cuminabs(N, toAccessorArray( x ), -2, x.length-1, toAccessorArray( y ), -1, 2); expected = [ 1.0, 3.0, 5.0, 0.0, 0.0 ]; t.deepEqual( y, expected, 'returns expected value' ); From 8874c14cb49d9d6cc66fd6f60deeda2bae00577d Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 11:56:22 +0530 Subject: [PATCH 12/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 8 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- From 55c692ec18ada88f811610c810d161c73b43a003 Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 11:57:38 +0530 Subject: [PATCH 13/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 8 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- From bf990ad483b3609dc5cbf9b075dd8485ff8c5b7a Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 11:58:50 +0530 Subject: [PATCH 14/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 8 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/cuminabs/test/test.ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js index 0dc1c206d05c..b71969c00f93 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js @@ -395,7 +395,7 @@ tape( 'the function supports negative strides (accessor)', function test( t ) { ]; N = 3; - cuminabs(N, toAccessorArray( x ), -2, x.length-1, toAccessorArray( y ), -1, 2); + cuminabs(N, toAccessorArray(x), -2, x.length - 1, toAccessorArray(y), -1, 2); expected = [ 1.0, 3.0, 5.0, 0.0, 0.0 ]; t.deepEqual( y, expected, 'returns expected value' ); From 91eed3d7d476c7c594790e51e4583da78d6270e7 Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 12:06:13 +0530 Subject: [PATCH 15/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 9 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/stats/base/cuminabs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/README.md b/lib/node_modules/@stdlib/stats/base/cuminabs/README.md index ff553941509b..d4625900c37d 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/README.md +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/README.md @@ -137,6 +137,7 @@ cuminabs.ndarray( 4, x, 2, 1, y, -1, y.length-1 ); ```javascript var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var cuminabs = require( '@stdlib/stats/base/cuminabs' ); +var Float64Array = require( '@stdlib/array/float64' ); var x = discreteUniform( 10, 0, 100, { 'dtype': 'float64' From 29d0213dd5d85f673c8e284b37cfab3b18d29f2a Mon Sep 17 00:00:00 2001 From: jsndz Date: Sun, 16 Mar 2025 12:43:04 +0530 Subject: [PATCH 16/28] fixup! refactor(stats/base/cuminabs): Fixed lint error 10 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/stats/base/cuminabs/docs/repl.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/cuminabs/docs/repl.txt index 08f91228a4b4..6fc6f14c52d4 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/docs/repl.txt @@ -2,8 +2,8 @@ {{alias}}( N, x, strideX, y, strideY ) Computes the cumulative minimum absolute value of a strided array. - The `N` and stride parameters determine which elements in the strided arrays are - accessed at runtime. + The `N` and stride parameters determine which elements in the strided + arrays are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -56,6 +56,7 @@ > y0 [ 0.0, 0.0, 0.0, 2.0, 2.0, 1.0 ] + {{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) Computes the cumulative minimum absolute value of a strided array using alternative indexing semantics. From 6d262827b4a86db8176744a00a0a74cbf4dc9350 Mon Sep 17 00:00:00 2001 From: Jaison D Souza <123267719+jsndz@users.noreply.github.com> Date: Sun, 16 Mar 2025 17:29:00 +0530 Subject: [PATCH 17/28] Update lib/node_modules/@stdlib/stats/base/cuminabs/README.md Co-authored-by: Aayush Khanna <96649223+aayush0325@users.noreply.github.com> Signed-off-by: Jaison D Souza <123267719+jsndz@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/base/cuminabs/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/README.md b/lib/node_modules/@stdlib/stats/base/cuminabs/README.md index d4625900c37d..6c553713655a 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/README.md +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/README.md @@ -188,7 +188,6 @@ console.log( y ); [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray - [@stdlib/stats/base/cumaxabs]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/cumaxabs From 594cc5394593c34e197382f4e59a6d7b986a9750 Mon Sep 17 00:00:00 2001 From: Jaison D Souza <123267719+jsndz@users.noreply.github.com> Date: Sun, 16 Mar 2025 17:29:08 +0530 Subject: [PATCH 18/28] Update lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js Co-authored-by: Aayush Khanna <96649223+aayush0325@users.noreply.github.com> Signed-off-by: Jaison D Souza <123267719+jsndz@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js index 36633bd06c1b..80c9ffe9bf7c 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js @@ -70,7 +70,7 @@ function cuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) { ybuf = y.data; // Cache references to element accessors: - xget = x.accessors[0]; + xget = x.accessors[ 0 ]; yset = y.accessors[1]; ix = offsetX; From ab417367ebd7ba050a0365a29f0c93c0239486c4 Mon Sep 17 00:00:00 2001 From: Jaison D Souza <123267719+jsndz@users.noreply.github.com> Date: Sun, 16 Mar 2025 17:30:06 +0530 Subject: [PATCH 19/28] Update lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js Co-authored-by: Aayush Khanna <96649223+aayush0325@users.noreply.github.com> Signed-off-by: Jaison D Souza <123267719+jsndz@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js index 80c9ffe9bf7c..a63d3e812846 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js @@ -71,7 +71,7 @@ function cuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) { // Cache references to element accessors: xget = x.accessors[ 0 ]; - yset = y.accessors[1]; + yset = y.accessors[ 1 ]; ix = offsetX; iy = offsetY; From 5c8b1b45c4f05f96d496af35e63e874c11efe5b9 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 19 Mar 2025 02:51:50 -0700 Subject: [PATCH 20/28] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/cuminabs/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/README.md b/lib/node_modules/@stdlib/stats/base/cuminabs/README.md index 6c553713655a..f160da827e6a 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/README.md +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/README.md @@ -102,7 +102,7 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetY**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative minimum absolute value of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative minimum absolute value of every other element in `x` starting from the second element and to store in the last `N` elements of `y` starting from the last element ```javascript var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; @@ -142,9 +142,9 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = discreteUniform( 10, 0, 100, { 'dtype': 'float64' }); -var y = new Float64Array( x.length ); - console.log( x ); + +var y = new Float64Array( x.length ); console.log( y ); cuminabs( x.length, x, 1, y, -1 ); From ffbd6e770d9facbc76f4982811445ec3f726cf17 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 19 Mar 2025 02:55:35 -0700 Subject: [PATCH 21/28] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/stats/base/cuminabs/docs/types/test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/test.ts index bc7d86e1705e..b3a05da956a3 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/docs/types/test.ts @@ -27,7 +27,7 @@ import cuminabs = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - cuminabs( x.length, x, 1, y, 1 ); // $ExpectType NumericArray + cuminabs( x.length, x, 1, y, 1 ); // $ExpectType Float64Array cuminabs( x.length, new AccessorArray( x ), 1, new AccessorArray( y ), 1 ); // $ExpectType AccessorArray } @@ -125,7 +125,7 @@ import cuminabs = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - cuminabs.ndarray( x.length, x, 1, 0, y, 1, 0 ); // $ExpectType NumericArray + cuminabs.ndarray( x.length, x, 1, 0, y, 1, 0 ); // $ExpectType Float64Array cuminabs.ndarray( x.length, new AccessorArray( x ), 1, 0, new AccessorArray( y ), 1, 0 ); // $ExpectType AccessorArray } From a7c4a54d8ef57bd74c6880450cca74814eb38263 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 19 Mar 2025 02:56:18 -0700 Subject: [PATCH 22/28] docs: update example Signed-off-by: Athan --- .../@stdlib/stats/base/cuminabs/examples/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/examples/index.js b/lib/node_modules/@stdlib/stats/base/cuminabs/examples/index.js index aee1bc8caad9..055adc42bf1f 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/examples/index.js @@ -25,9 +25,9 @@ var cuminabs = require( './../lib' ); var x = discreteUniform(10, -50, 50, { 'dtype': 'float64' }); -var y = new Float64Array( x.length ); - console.log( x ); + +var y = new Float64Array( x.length ); console.log( y ); cuminabs( x.length, x, 1, y, -1 ); From b1829ab8f0e9baa79ac21625fa9b10e1c011004b Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 19 Mar 2025 02:59:00 -0700 Subject: [PATCH 23/28] docs: remove unused import Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js index 3ac39869b76e..7970d017c29b 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/ndarray.js @@ -41,8 +41,6 @@ var accessors = require( './accessors.js' ); * @returns {NumericArray} output array * * @example -* 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 y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; * From f326581ca01c97c1b35278e367d762c2ba6f0acc Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 19 Mar 2025 02:59:34 -0700 Subject: [PATCH 24/28] style: add missing space Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js index a63d3e812846..a5067486bfff 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/lib/accessors.js @@ -76,7 +76,7 @@ function cuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) { ix = offsetX; iy = offsetY; - min = abs( xget( xbuf, ix )); + min = abs( xget( xbuf, ix ) ); yset( ybuf, iy, min ); iy += strideY; From 4f719b1fafb0d368e5357d0d638809919c54deb9 Mon Sep 17 00:00:00 2001 From: Jaison D Souza <123267719+jsndz@users.noreply.github.com> Date: Wed, 19 Mar 2025 17:29:39 +0530 Subject: [PATCH 25/28] Update lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js Co-authored-by: Athan Signed-off-by: Jaison D Souza <123267719+jsndz@users.noreply.github.com> --- .../@stdlib/stats/base/cuminabs/test/test.cuminabs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js index 59a454b4938a..646b76b649ea 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.cuminabs.js @@ -196,8 +196,8 @@ tape( 'the function returns a reference to the output array (accessor)', functio var x; var y; - x = toAccessorArray([ 1.0, 2.0, 3.0, 4.0, 5.0 ]); - y = toAccessorArray([ 0.0, 0.0, 0.0, 0.0, 0.0 ]); + x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); out = cuminabs( x.length, x, 1, y, 1 ); t.strictEqual( out, y, 'same reference' ); From 5df0d999004fb5076c2d6fa1705dcb0f49d9552c Mon Sep 17 00:00:00 2001 From: Jaison D Souza <123267719+jsndz@users.noreply.github.com> Date: Wed, 19 Mar 2025 17:30:19 +0530 Subject: [PATCH 26/28] Update lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js Co-authored-by: Athan Signed-off-by: Jaison D Souza <123267719+jsndz@users.noreply.github.com> --- .../@stdlib/stats/base/cuminabs/test/test.ndarray.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js index b71969c00f93..c8093f3462c0 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js @@ -195,8 +195,8 @@ tape( 'the function returns a reference to the output array (accessor)', functio var x; var y; - x = toAccessorArray([ 1.0, 2.0, 3.0, 4.0, 5.0 ]); - y = toAccessorArray([ 0.0, 0.0, 0.0, 0.0, 0.0 ]); + x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); out = cuminabs( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( out, y, 'same reference' ); From 4913bd7c24ad688fe78b386e5c7d9313740623de Mon Sep 17 00:00:00 2001 From: Jaison D Souza <123267719+jsndz@users.noreply.github.com> Date: Wed, 19 Mar 2025 17:30:32 +0530 Subject: [PATCH 27/28] Update lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js Co-authored-by: Athan Signed-off-by: Jaison D Souza <123267719+jsndz@users.noreply.github.com> --- .../@stdlib/stats/base/cuminabs/test/test.ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js index c8093f3462c0..6674f0c91f01 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js @@ -116,7 +116,7 @@ tape( 'the function calculates the cumulative minimum absolute value (accessor)' x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ]; y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; - cuminabs(x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0); + cuminabs( x.length, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 ); expected = [ 1.0, From 3f25ab5342a9de75bc428682650b085d296330c7 Mon Sep 17 00:00:00 2001 From: Jaison D Souza <123267719+jsndz@users.noreply.github.com> Date: Wed, 19 Mar 2025 18:02:17 +0530 Subject: [PATCH 28/28] fixup! refactor(stats/base/cuminabs): Update test.ndarray.js Signed-off-by: Jaison D Souza <123267719+jsndz@users.noreply.github.com> --- .../@stdlib/stats/base/cuminabs/test/test.ndarray.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js index 6674f0c91f01..182d3dc6c65f 100644 --- a/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/cuminabs/test/test.ndarray.js @@ -275,7 +275,7 @@ tape( 'the function supports an `x` stride (accessor)', function test( t ) { ]; N = 3; - cuminabs(N, toAccessorArray( x ), 2, 0, toAccessorArray( y ), 1, 0); + cuminabs( N, toAccessorArray( x ), 2, 0, toAccessorArray( y ), 1, 0 ); expected = [ 1.0, 1.0, 1.0, 0.0, 0.0 ]; t.deepEqual( y, expected, 'returns expected value' ); @@ -395,7 +395,7 @@ tape( 'the function supports negative strides (accessor)', function test( t ) { ]; N = 3; - cuminabs(N, toAccessorArray(x), -2, x.length - 1, toAccessorArray(y), -1, 2); + cuminabs( N, toAccessorArray(x), -2, x.length - 1, toAccessorArray(y), -1, 2 ); expected = [ 1.0, 3.0, 5.0, 0.0, 0.0 ]; t.deepEqual( y, expected, 'returns expected value' );