From 55940c4156da92bcf621d45f6dba6c8a048849bb Mon Sep 17 00:00:00 2001 From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com> Date: Mon, 31 Mar 2025 14:39:18 +0530 Subject: [PATCH 01/19] refactor and add protocol support to stats/base/nanmin-by --- .gitignore | 3 + .../@stdlib/stats/base/nanmin-by/README.md | 27 +-- .../base/nanmin-by/benchmark/benchmark.js | 25 ++- .../nanmin-by/benchmark/benchmark.ndarray.js | 25 ++- .../stats/base/nanmin-by/docs/repl.txt | 16 +- .../base/nanmin-by/docs/types/index.d.ts | 26 +-- .../stats/base/nanmin-by/docs/types/test.ts | 12 +- .../stats/base/nanmin-by/examples/index.js | 13 +- .../stats/base/nanmin-by/lib/accessors.js | 102 ++++++++++ .../stats/base/nanmin-by/lib/nanmin_by.js | 54 +---- .../stats/base/nanmin-by/lib/ndarray.js | 23 ++- .../base/nanmin-by/test/test.nanmin_by.js | 184 +++++++++++++++++- .../stats/base/nanmin-by/test/test.ndarray.js | 176 ++++++++++++++++- package.json | 3 +- 14 files changed, 560 insertions(+), 129 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js diff --git a/.gitignore b/.gitignore index 16b03f7702dd..999c7c418f51 100644 --- a/.gitignore +++ b/.gitignore @@ -192,3 +192,6 @@ jsconfig.json # Cursor # ########## .cursorignore +package.json +etc/npm/deps.txt +etc/npm/deps.txt diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/README.md b/lib/node_modules/@stdlib/stats/base/nanmin-by/README.md index 40a2f27cf662..7d069fa601b1 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/README.md +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2020 The Stdlib Authors. +Copyright (c) 2025 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ limitations under the License. var nanminBy = require( '@stdlib/stats/base/nanmin-by' ); ``` -#### nanminBy( N, x, stride, clbk\[, thisArg] ) +#### nanminBy( N, x, strideX, clbk\[, thisArg] ) Calculates the minimum value of strided array `x` via a callback function, ignoring `NaN` values. @@ -49,7 +49,7 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions). -- **stride**: index increment. +- **strideX**: index increment. - **clbk**: callback function. - **thisArg**: execution context (_optional_). @@ -81,7 +81,7 @@ var cnt = context.count; // returns 10 ``` -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element +The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element ```javascript var floor = require( '@stdlib/math/base/special/floor' ); @@ -119,7 +119,7 @@ var v = nanminBy( N, x1, 2, accessor ); // returns -12.0 ``` -#### nanminBy.ndarray( N, x, stride, offset, clbk\[, thisArg] ) +#### nanminBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] ) Calculates the minimum value of strided array `x` via a callback function, ignoring `NaN` values and using alternative indexing semantics. @@ -136,9 +136,9 @@ var v = nanminBy.ndarray( x.length, x, 1, 0, accessor ); The function has the following additional parameters: -- **offset**: starting index. +- **offsetX**: starting index. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x` +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offsetX` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x` ```javascript function accessor( v ) { @@ -163,6 +163,7 @@ var v = nanminBy.ndarray( 3, x, 1, x.length-3, accessor ); - A provided callback function should return a numeric value. - If a provided callback function returns `NaN`, the value is ignored. - If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is ignored. +- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). - When possible, prefer using [`dnanmin`][@stdlib/stats/strided/dnanmin], [`snanmin`][@stdlib/stats/strided/snanmin], and/or [`nanmin`][@stdlib/stats/base/nanmin], as, depending on the environment, these interfaces are likely to be significantly more performant. @@ -176,23 +177,23 @@ var v = nanminBy.ndarray( 3, x, 1, x.length-3, accessor ); ```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var nanminBy = require( '@stdlib/stats/base/nanmin-by' ); -function fill() { - if ( randu() < 0.2 ) { +function rand() { + if( bernoulli( 0.8 ) < 1 ) { return NaN; } - return discreteUniform( -50, 50 ); + return uniform( -50.0, 50.0 ); } function accessor( v ) { return v * 2.0; } -var x = filledarrayBy( 10, 'float64', fill ); +var x = filledarrayBy( 10, 'float64', rand ); console.log( x ); var v = nanminBy( x.length, x, 1, accessor ); diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js index facdddf5131a..d15658068a91 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; @@ -37,6 +39,13 @@ var nanminBy = require( './../lib/nanmin_by.js' ); * @param {number} value - array element * @returns {number} accessed value */ +function rand() { + if( bernoulli( 0.8 ) < 1 ) { + return NaN; + } + return uniform( -50.0, 50.0 ); +} + function accessor( value ) { return value * 2.0; } @@ -49,17 +58,7 @@ function accessor( value ) { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - if ( randu() < 0.2 ) { - x.push( NaN ); - } else { - x.push( ( randu()*20.0 ) - 10.0 ); - } - } + var x = filledarrayBy( len, "float64", rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js index 1571c3c927ed..55896f5eaf03 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; @@ -37,6 +39,13 @@ var nanminBy = require( './../lib/ndarray.js' ); * @param {number} value - array element * @returns {number} accessed value */ +function rand() { + if( bernoulli( 0.8 ) < 1 ) { + return NaN; + } + return uniform( -50.0, 50.0 ); +} + function accessor( value ) { return value * 2.0; } @@ -49,17 +58,7 @@ function accessor( value ) { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - if ( randu() < 0.2 ) { - x.push( NaN ); - } else { - x.push( ( randu()*20.0 ) - 10.0 ); - } - } + var x = filledarrayBy( len, "float64", rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt index 31e3189ca9d0..9938bec9e8e5 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt @@ -1,9 +1,9 @@ -{{alias}}( N, x, stride, clbk[, thisArg] ) +{{alias}}( N, x, strideX, clbk[, thisArg] ) Calculates the minimum value of a strided array via a callback function, ignoring `NaN` values. - The `N` and `stride` parameters determine which elements in `x` are accessed + The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use typed @@ -34,7 +34,7 @@ Input array/collection. If provided an object, the object must be array- like (excluding strings and functions). - stride: integer + strideX: integer Index increment for `x`. clbk: Function @@ -56,7 +56,7 @@ > {{alias}}( x.length, x, 1, accessor ) -10.0 - // Using `N` and `stride` parameters: + // Using `N` and `strideX` parameters: > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, NaN, -3.0 ]; > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); > {{alias}}( N, x, 2, accessor ) @@ -69,12 +69,12 @@ > {{alias}}( N, x1, 2, accessor ) -12.0 -{{alias}}.ndarray( N, x, stride, offset, clbk[, thisArg] ) +{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] ) Calculates the minimum value of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the `offset` parameter supports indexing semantics based on a + buffer, the `offsetX` parameter supports indexing semantics based on a starting index. Parameters @@ -86,10 +86,10 @@ Input array/collection. If provided an object, the object must be array- like (excluding strings and functions). - stride: integer + strideX: integer Index increment for `x`. - offset: integer + offsetX: integer Starting index of `x`. clbk: Function diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/index.d.ts index 05666501132c..a61b8c56b344 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,11 @@ /// -import { Collection } from '@stdlib/types/array'; +import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; +/** +* Input array. +*/ +type InputArray = NumericArray | Collection | AccessorArrayLike; /** * Returns an accessed value. @@ -51,7 +55,7 @@ type Binary = ( this: U, value: T, aidx: number ) => number | void; * * @param value - array element * @param aidx - array index -* @param sidx - strided index (offset + aidx*stride) +* @param sidx - strided index (offsetX + aidx*strideX) * @returns accessed value */ type Ternary = ( this: U, value: T, aidx: number, sidx: number ) => number | void; @@ -61,7 +65,7 @@ type Ternary = ( this: U, value: T, aidx: number, sidx: number ) => number * * @param value - array element * @param aidx - array index -* @param sidx - strided index (offset + aidx*stride) +* @param sidx - strided index (offsetX + aidx*strideX) * @param array - input array * @returns accessed value */ @@ -102,7 +106,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length + * @param strideX - stride length * @param clbk - callback * @param thisArg - execution context * @returns minimum value @@ -117,7 +121,7 @@ interface Routine { * var v = nanminBy( x.length, x, 1, accessor ); * // returns -10.0 */ - ( N: number, x: Collection, stride: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + ( N: number, x: InputArray, stride: number, clbk: Callback, thisArg?: ThisParameterType> ): number; /** * Calculates the minimum value of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics. @@ -139,8 +143,8 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length - * @param offset - starting index + * @param strideX - stride length + * @param offsetX - starting index * @param clbk - callback * @param thisArg - execution context * @returns minimum value @@ -155,7 +159,7 @@ interface Routine { * var v = nanminBy.ndarray( x.length, x, 1, 0, accessor ); * // returns -10.0 */ - ndarray( N: number, x: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + ndarray( N: number, x: InputArray, strideX: number, offsetX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; } /** @@ -167,7 +171,7 @@ interface Routine { * * - `value`: array element * - `aidx`: array index -* - `sidx`: strided index (offset + aidx*stride) +* - `sidx`: strided index (offsetX + aidx*strideX) * - `array`: input array * * - The callback function should return a numeric value. @@ -178,7 +182,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array -* @param stride - stride length +* @param strideX - stride length * @param clbk - callback * @param thisArg - execution context * @returns minimum value diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/test.ts index eeebd51df143..5fd3c233c106 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,9 @@ * limitations under the License. */ +import toAccessorArray from '@stdlib/array/base/to-accessor-array'; import nanminBy = require( './index' ); +import AccessorArray = require( '@stdlib/array/base/accessor' ); const accessor = (): number => { return 5.0; @@ -29,8 +31,8 @@ const accessor = (): number => { { const x = new Float64Array( 10 ); - nanminBy( x.length, x, 1, accessor ); // $ExpectType number - nanminBy( x.length, x, 1, accessor, {} ); // $ExpectType number + nanminBy( x.length, toAccessorArray( x ), 1, accessor ); // $ExpectType number + nanminBy( x.length, toAccessorArray( x ), 1, accessor, {} ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -101,8 +103,8 @@ const accessor = (): number => { { const x = new Float64Array( 10 ); - nanminBy.ndarray( x.length, x, 1, 0, accessor ); // $ExpectType number - nanminBy.ndarray( x.length, x, 1, 0, accessor, {} ); // $ExpectType number + nanminBy.ndarray( x.length, toAccessorArray( x ), 1, 0, accessor ); // $ExpectType number + nanminBy.ndarray( x.length, toAccessorArray( x ), 1, 0, accessor, {} ); // $ExpectType number } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/examples/index.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/examples/index.js index 47da3a4f59c7..d4ef47ef0e19 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,22 +19,23 @@ 'use strict'; var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var nanminBy = require( './../lib' ); -function fill() { - if ( randu() < 0.2 ) { +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { return NaN; } - return discreteUniform( -50, 50 ); + return uniform( -50.0, 50.0 ); } function accessor( v ) { return v * 2.0; } -var x = filledarrayBy( 10, 'float64', fill ); +var x = filledarrayBy( 10, 'float64', rand ); console.log( x ); var v = nanminBy( x.length, x, 1, accessor ); diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js new file mode 100644 index 000000000000..5c8b03088e2e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js @@ -0,0 +1,102 @@ +/** +* @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 isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); + + +// MAIN // + +/** +* Calculates the minimum value of a strided array via a callback function, ignoring `NaN` values. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Collection} x - input array/collection +* @param {integer} strideX - index increment +* @param {NonNegativeInteger} offsetX - starting index +* @param {Callback} clbk - callback +* @param {*} [thisArg] - execution context +* @returns {number} minimum value +* +* @example +* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ]; +* +* function accessor( v ) { +* return v * 2.0; +* } +* +* var v = nanminBy( x.length, x, 1, 0, accessor ); +* // returns -10.0 +*/ +function nanminBy( N, x, strideX, offsetX, clbk, thisArg ) { + var xbuf; + var get; + var max; + var min; + var ix; + var v; + var i; + + // Cache reference to array data: + xbuf = x.data; + + // Cache a reference to the element accessor: + get = x.accessors[0]; + if ( N <= 0 ) { + return NaN; + } + if ( N === 1 || strideX === 0 ) { + v = clbk.call( thisArg, get( xbuf, 0 ), 0, 0, x ); + if ( v === void 0 || isnan( v ) ) { + return NaN; + } + return v; + } + ix = offsetX; + for ( i = 0; i < N; i++ ) { + min = clbk.call( thisArg, get( xbuf, ix ), i, ix, x ); + if ( min === min && min !== void 0 ) { + break; + } + ix += strideX; + } + if ( i === N ) { + return NaN; + } + i += 1; + for( i ; i < N ; i++ ) { + ix += strideX; + v = clbk.call( thisArg, get( xbuf, ix ), i, ix, x ); + if ( v === void 0 || isnan( v ) ) { + continue; + } + if( v < min || ( v === min && isNegativeZero( v ) ) ) { + min = v; + } + } + return min; +} + + +// EXPORTS // + +module.exports = nanminBy; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/nanmin_by.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/nanmin_by.js index d27553636d96..bf097f60d678 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/nanmin_by.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/nanmin_by.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,9 +20,8 @@ // MODULES // -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); - +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); // MAIN // @@ -31,7 +30,7 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array/collection -* @param {integer} stride - index increment +* @param {integer} strideX - index increment * @param {Callback} clbk - callback * @param {*} [thisArg] - execution context * @returns {number} minimum value @@ -46,49 +45,8 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); * var v = nanminBy( x.length, x, 1, accessor ); * // returns -10.0 */ -function nanminBy( N, x, stride, clbk, thisArg ) { - var min; - var ix; - var v; - var i; - - if ( N <= 0 ) { - return NaN; - } - if ( N === 1 || stride === 0 ) { - v = clbk.call( thisArg, x[ 0 ], 0, 0, x ); - if ( v === void 0 ) { - return NaN; - } - return v; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - for ( i = 0; i < N; i++ ) { - min = clbk.call( thisArg, x[ ix ], i, ix, x ); - if ( min === min && min !== void 0 ) { - break; - } - ix += stride; - } - if ( i === N ) { - return NaN; - } - i += 1; - for ( i; i < N; i++ ) { - ix += stride; - v = clbk.call( thisArg, x[ ix ], i, ix, x ); - if ( v === void 0 || isnan( v ) ) { - continue; - } - if ( v < min || ( v === min && isNegativeZero( v ) ) ) { - min = v; - } - } - return min; +function nanminBy( N, x, strideX, clbk, thisArg ) { + return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk , thisArg ); } diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/ndarray.js index 4e51a5e2bace..41dbf3fc2f98 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var accessors = require( './accessors.js' ); // MAIN // @@ -31,8 +33,8 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array/collection -* @param {integer} stride - index increment -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - index increment +* @param {NonNegativeInteger} offsetX - starting index * @param {Callback} clbk - callback * @param {*} [thisArg] - execution context * @returns {number} minimum value @@ -47,36 +49,41 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); * var v = nanminBy( x.length, x, 1, 0, accessor ); * // returns -10.0 */ -function nanminBy( N, x, stride, offset, clbk, thisArg ) { +function nanminBy( N, x, strideX, offsetX, clbk, thisArg ) { var min; var ix; + var o; var v; var i; if ( N <= 0 ) { return NaN; } - if ( N === 1 || stride === 0 ) { + o = arraylike2object( x ); + if( o.accessorProtocol ) { + return accessors( N, o, strideX, offsetX, clbk, thisArg ); + } + if ( N === 1 || strideX === 0 ) { v = clbk.call( thisArg, x[ 0 ], 0, 0, x ); if ( v === void 0 ) { return NaN; } return v; } - ix = offset; + ix = offsetX; for ( i = 0; i < N; i++ ) { min = clbk.call( thisArg, x[ ix ], i, ix, x ); if ( min === min && min !== void 0 ) { break; } - ix += stride; + ix += strideX; } if ( i === N ) { return NaN; } i += 1; for ( i; i < N; i++ ) { - ix += stride; + ix += strideX; v = clbk.call( thisArg, x[ ix ], i, ix, x ); if ( v === void 0 || isnan( v ) ) { continue; diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.nanmin_by.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.nanmin_by.js index d6489f16ccf6..03b46670bc05 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.nanmin_by.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.nanmin_by.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ var tape = require( 'tape' ); var floor = require( '@stdlib/math/base/special/floor' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var Float64Array = require( '@stdlib/array/float64' ); @@ -87,6 +88,42 @@ tape( 'the function calculates the minimum value of a strided array via a callba t.end(); }); +tape( 'the function calculates the minimum value of a strided array via a callback function, ignoring NaN values (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, NaN, 3.0 ]; + v = nanminBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( v, -8.0, 'returns expected value' ); + + x = [ -4.0, NaN, -5.0 ]; + v = nanminBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( v, -10.0, 'returns expected value' ); + + x = [ 0.0, -0.0, NaN, 0.0 ]; + v = nanminBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = nanminBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = nanminBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // sparse array + v = nanminBy( x.length, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // sparse array + x[ 2 ] = 1.0; + v = nanminBy( x.length, toAccessorArray( x), 1, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { var x; var v; @@ -102,6 +139,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = nanminBy( 0, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = nanminBy( -1, x, 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter equal to `1`, the function returns the first accessed element', function test( t ) { var x; var v; @@ -118,6 +170,22 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first t.end(); }); +tape( 'if provided an `N` parameter equal to `1`, the function returns the first accessed element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = nanminBy( 1, toAccessorArray( x ), 1, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // sparse array + v = nanminBy( 1, toAccessorArray( x ), 1, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports a `stride` parameter', function test( t ) { var N; var x; @@ -143,6 +211,31 @@ tape( 'the function supports a `stride` parameter', function test( t ) { t.end(); }); +tape( 'the function supports a `stride` parameter (accessors)', function test( t ) { + var N; + var x; + var v; + + x = [ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0, + NaN, // 4 + NaN + ]; + + N = floor( x.length / 2 ); + v = nanminBy( N, toAccessorArray( x ), 2, accessor ); + + t.strictEqual( v, -4.0, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports a negative `stride` parameter', function test( t ) { var N; var x; @@ -168,6 +261,31 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) t.end(); }); +tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) { + var N; + var x; + var v; + + x = [ + NaN, // 4 + NaN, + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]; + + N = floor( x.length / 2 ); + v = nanminBy( N, toAccessorArray( x ), -2, accessor ); + + t.strictEqual( v, -4.0, 'returns expected value' ); + t.end(); +}); + tape( 'if provided a `stride` parameter equal to `0`, the function returns the first accessed element', function test( t ) { var x; var v; @@ -184,6 +302,22 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f t.end(); }); +tape( 'if provided a `stride` parameter equal to `0`, the function returns the first accessed element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = nanminBy( x.length, toAccessorArray( x ), 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // sparse array + v = nanminBy( 1, toAccessorArray( x ), 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var x0; var x1; @@ -213,6 +347,35 @@ tape( 'the function supports view offsets', function test( t ) { t.end(); }); +tape( 'the function supports view offsets (accessors)', function test( t ) { + var x0; + var x1; + var N; + var v; + + x0 = new Float64Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0, // 3 + 6.0, + NaN, // 4 + NaN + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + N = floor(x1.length / 2); + + v = nanminBy( N, toAccessorArray( x1 ), 2, accessor ); + t.strictEqual( v, -4.0, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports providing a callback execution context', function test( t ) { var ctx; var x; @@ -231,3 +394,22 @@ tape( 'the function supports providing a callback execution context', function t return v * 2.0; } }); + +tape( 'the function supports providing a callback execution context (accessors)', function test( t ) { + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, NaN, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + nanminBy( x.length, toAccessorArray( x ), 1, accessor, ctx ); + + t.strictEqual( ctx.count, x.length, 'returns expected value' ); + t.end(); + + function accessor( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v * 2.0; + } +}); diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.ndarray.js index 32bafbcc27bd..8ca59b2ad523 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.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. @@ -22,6 +22,7 @@ var tape = require( 'tape' ); var floor = require( '@stdlib/math/base/special/floor' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var nanminBy = require( './../lib/ndarray.js' ); @@ -86,6 +87,42 @@ tape( 'the function calculates the minimum value of a strided array via a callba t.end(); }); +tape( 'the function calculates the minimum value of a strided array via a callback function, ignoring NaN values (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, NaN, 3.0 ]; + v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( v, -8.0, 'returns expected value' ); + + x = [ -4.0, NaN, -5.0 ]; + v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( v, -10.0, 'returns expected value' ); + + x = [ 0.0, -0.0, NaN, 0.0 ]; + v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // sparse array + v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = new Array( 5 ); // sparse array + x[ 2 ] = 1.0; + v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { var x; var v; @@ -101,6 +138,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = nanminBy( 0, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = nanminBy( -1, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter equal to `1`, the function returns the first accessed element', function test( t ) { var x; var v; @@ -117,6 +169,22 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first t.end(); }); +tape( 'if provided an `N` parameter equal to `1`, the function returns the first accessed element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = nanminBy( 1, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // sparse array + v = nanminBy( 1, toAccessorArray( x ), 1, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports a `stride` parameter', function test( t ) { var N; var x; @@ -142,6 +210,31 @@ tape( 'the function supports a `stride` parameter', function test( t ) { t.end(); }); +tape( 'the function supports a `stride` parameter (accessors)', function test( t ) { + var N; + var x; + var v; + + x = [ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0, + NaN, // 4 + NaN + ]; + + N = floor( x.length / 2 ); + v = nanminBy( N, toAccessorArray( x ), 2, 0, accessor ); + + t.strictEqual( v, -4.0, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports a negative `stride` parameter', function test( t ) { var N; var x; @@ -167,6 +260,31 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) t.end(); }); +tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) { + var N; + var x; + var v; + + x = [ + NaN, // 4 + NaN, + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]; + + N = floor( x.length / 2 ); + v = nanminBy( N, toAccessorArray( x ), -2, 8, accessor ); + + t.strictEqual( v, -4.0, 'returns expected value' ); + t.end(); +}); + tape( 'if provided a `stride` parameter equal to `0`, the function returns the first accessed element', function test( t ) { var x; var v; @@ -183,6 +301,22 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f t.end(); }); +tape( 'if provided a `stride` parameter equal to `0`, the function returns the first accessed element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = nanminBy( x.length, toAccessorArray( x ), 0, 0, accessor ); + t.strictEqual( v, 2.0, 'returns expected value' ); + + x = new Array( 1 ); // sparse array + v = nanminBy( 1, toAccessorArray( x ), 0, 0, accessor ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports an offset parameter', function test( t ) { var x; var v; @@ -204,6 +338,27 @@ tape( 'the function supports an offset parameter', function test( t ) { t.end(); }); +tape( 'the function supports an offset parameter (accessors)', function test( t ) { + var x; + var v; + + x = [ + 1.0, + -2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + -6.0, // 2 + NaN, + NaN // 3 + ]; + + v = nanminBy( 4, toAccessorArray( x ), 2, 1, accessor ); + t.strictEqual( v, -12.0, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports providing a callback execution context', function test( t ) { var ctx; var x; @@ -222,3 +377,22 @@ tape( 'the function supports providing a callback execution context', function t return v * 2.0; } }); + +tape( 'the function supports providing a callback execution context (accessors)', function test( t ) { + var ctx; + var x; + + x = [ 1.0, 2.0, 3.0, NaN, 4.0, 5.0 ]; + ctx = { + 'count': 0 + }; + nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor, ctx ); + + t.strictEqual( ctx.count, x.length, 'returns expected value' ); + t.end(); + + function accessor( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v * 2.0; + } +}); diff --git a/package.json b/package.json index 25b79ee80bb9..1ca451cfbe4d 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,7 @@ "directories": { "doc": "./docs", "example": "./examples", - "lib": "./lib", - "test": "./test" + "lib": "./lib" }, "types": "./docs/types", "scripts": { From 42164b8d3e09e25ffef44e16414446ee571e58b6 Mon Sep 17 00:00:00 2001 From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com> Date: Mon, 31 Mar 2025 14:43:30 +0530 Subject: [PATCH 02/19] Delete package.json Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com> --- package.json | 295 --------------------------------------------------- 1 file changed, 295 deletions(-) delete mode 100644 package.json diff --git a/package.json b/package.json deleted file mode 100644 index 1ca451cfbe4d..000000000000 --- a/package.json +++ /dev/null @@ -1,295 +0,0 @@ -{ - "name": "@stdlib/stdlib", - "version": "0.3.2", - "description": "Standard library.", - "license": "Apache-2.0 AND BSL-1.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/stdlib" - }, - "bin": { - "stdlib": "./bin/cli" - }, - "main": "./lib", - "browser": { - "process": "process/" - }, - "directories": { - "doc": "./docs", - "example": "./examples", - "lib": "./lib" - }, - "types": "./docs/types", - "scripts": { - "notes": "make notes", - "lint": "make lint", - "repl": "make repl", - "test": "make test", - "test-cov": "make test-cov", - "view-cov": "make view-cov", - "examples": "make examples", - "benchmark": "make benchmark", - "clean": "make clean", - "check-deps": "make check-deps", - "check-licenses": "make check-licenses" - }, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": { - "@stdlib/array": "^0.3.3", - "@stdlib/assert": "^0.3.3", - "@stdlib/bench": "^0.4.3", - "@stdlib/bigint": "^0.3.3", - "@stdlib/blas": "^0.3.3", - "@stdlib/boolean": "^0.3.3", - "@stdlib/buffer": "^0.3.3", - "@stdlib/cli": "^0.3.3", - "@stdlib/complex": "^0.3.3", - "@stdlib/console": "^0.3.3", - "@stdlib/constants": "^0.3.3", - "@stdlib/datasets": "^0.3.0", - "@stdlib/error": "^0.3.3", - "@stdlib/fs": "^0.3.3", - "@stdlib/function": "^0.3.3", - "@stdlib/iter": "^0.3.3", - "@stdlib/lapack": "^0.1.3", - "@stdlib/math": "^0.3.3", - "@stdlib/ml": "^0.3.3", - "@stdlib/namespace": "^0.3.3", - "@stdlib/napi": "^0.3.3", - "@stdlib/ndarray": "^0.3.3", - "@stdlib/net": "^0.3.3", - "@stdlib/nlp": "^0.3.3", - "@stdlib/number": "^0.3.3", - "@stdlib/object": "^0.3.3", - "@stdlib/os": "^0.3.3", - "@stdlib/plot": "^0.3.3", - "@stdlib/process": "^0.3.3", - "@stdlib/proxy": "^0.3.3", - "@stdlib/random": "^0.3.3", - "@stdlib/regexp": "^0.3.3", - "@stdlib/repl": "^0.3.3", - "@stdlib/simulate": "^0.3.3", - "@stdlib/slice": "^0.3.3", - "@stdlib/stats": "^0.3.3", - "@stdlib/streams": "^0.3.3", - "@stdlib/strided": "^0.3.3", - "@stdlib/string": "^0.3.3", - "@stdlib/symbol": "^0.3.3", - "@stdlib/time": "^0.3.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils": "^0.3.3", - "@stdlib/wasm": "^0.1.1", - "acorn": "^8.1.0", - "acorn-loose": "^8.0.2", - "acorn-walk": "^8.0.2", - "d3-format": "^1.0.0", - "d3-scale": "^1.0.0", - "d3-shape": "^1.0.0", - "d3-time-format": "^2.0.0", - "debug": "^2.6.9", - "glob": "^7.0.5", - "minimist": "^1.2.0", - "readable-stream": "^2.1.4", - "resolve": "^1.1.7", - "vdom-to-html": "^2.3.0", - "virtual-dom": "^2.1.1" - }, - "optionalDependencies": { - "node-gyp": "^9.3.1" - }, - "devDependencies": { - "0x": "^4.10.2", - "@cspell/eslint-plugin": "^8.8.0", - "@commitlint/cli": "^17.4.4", - "@commitlint/cz-commitlint": "^17.4.4", - "@conventional-commits/parser": "^0.4.1", - "@kaciras/deasync": "^1.0.1", - "@types/node": "^13.9.0", - "@typescript-eslint/parser": "^6.9.1", - "@typescript-eslint/eslint-plugin": "^6.9.1", - "ajv": "^5.2.2", - "browser-pack-flat": "^3.0.0", - "browserify": "^17.0.0", - "bundle-collapser": "^1.3.0", - "c8": "^7.12.0", - "chai": "^3.5.0", - "cheerio": "^1.0.0-rc.12", - "commitizen": "^4.3.0", - "common-shakeify": "^0.6.0", - "conventional-changelog-conventionalcommits": "^5.0.0", - "doctrine": "^3.0.0", - "editorconfig-checker": "^6.0.0", - "envify": "^4.0.0", - "eslint": "^8.57.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-expect-type": "^0.2.3", - "eslint-plugin-import": "^2.29.0", - "eslint-plugin-jsdoc": "^46.8.2", - "exorcist": "^2.0.0", - "factor-bundle": "^2.5.0", - "gh-pages": "git+https://github.com/Planeshifter/gh-pages.git#main", - "inquirer": "^8.0.0", - "jscodeshift": "^0.15.0", - "jsdoc": "^3.4.0", - "lunr": "^2.3.9", - "mathjax-node": "^2.0.1", - "mathjax-node-sre": "^3.0.0", - "mkdirp": "^0.5.1", - "mustache": "^4.0.0", - "parse-link-header": "^1.0.1", - "plato": "^1.5.0", - "process": "^0.11.10", - "proxyquire": "^2.0.0", - "proxyquire-universal": "^2.0.0", - "proxyquireify": "^3.1.1", - "read-installed": "^4.0.3", - "rehype": "^9.0.0", - "rehype-highlight": "^3.0.0", - "remark": "^11.0.1", - "remark-cli": "^7.0.0", - "remark-frontmatter": "^1.2.0", - "remark-html": "^10.0.0", - "remark-lint": "^6.0.0", - "remark-lint-blockquote-indentation": "^1.0.0", - "remark-lint-checkbox-character-style": "^1.0.0", - "remark-lint-checkbox-content-indent": "^1.0.0", - "remark-lint-code-block-style": "^1.0.0", - "remark-lint-definition-case": "^1.0.0", - "remark-lint-definition-spacing": "^1.0.0", - "remark-lint-emphasis-marker": "^1.0.0", - "remark-lint-fenced-code-flag": "^1.0.0", - "remark-lint-fenced-code-marker": "^1.0.0", - "remark-lint-file-extension": "^1.0.0", - "remark-lint-final-definition": "^1.0.0", - "remark-lint-final-newline": "^1.0.0", - "remark-lint-first-heading-level": "^1.1.0", - "remark-lint-hard-break-spaces": "^1.0.1", - "remark-lint-heading-increment": "^1.0.0", - "remark-lint-heading-style": "^1.0.0", - "remark-lint-linebreak-style": "^1.0.0", - "remark-lint-link-title-style": "^1.0.0", - "remark-lint-list-item-bullet-indent": "^1.0.0", - "remark-lint-list-item-content-indent": "^1.0.0", - "remark-lint-list-item-indent": "^1.0.0", - "remark-lint-list-item-spacing": "^1.1.0", - "remark-lint-maximum-heading-length": "^1.0.0", - "remark-lint-maximum-line-length": "^1.0.0", - "remark-lint-no-auto-link-without-protocol": "^1.0.0", - "remark-lint-no-blockquote-without-marker": "^2.0.0", - "remark-lint-no-consecutive-blank-lines": "^1.0.0", - "remark-lint-no-duplicate-definitions": "^1.0.0", - "remark-lint-no-duplicate-headings": "^1.0.0", - "remark-lint-no-duplicate-headings-in-section": "^1.0.0", - "remark-lint-no-emphasis-as-heading": "^1.0.0", - "remark-lint-no-empty-url": "^1.0.1", - "remark-lint-no-file-name-articles": "^1.0.0", - "remark-lint-no-file-name-consecutive-dashes": "^1.0.0", - "remark-lint-no-file-name-irregular-characters": "^1.0.0", - "remark-lint-no-file-name-mixed-case": "^1.0.0", - "remark-lint-no-file-name-outer-dashes": "^1.0.1", - "remark-lint-no-heading-content-indent": "^1.0.0", - "remark-lint-no-heading-indent": "^1.0.0", - "remark-lint-no-heading-like-paragraph": "^1.0.0", - "remark-lint-no-heading-punctuation": "^1.0.0", - "remark-lint-no-html": "^1.0.0", - "remark-lint-no-inline-padding": "^1.0.0", - "remark-lint-no-literal-urls": "^1.0.0", - "remark-lint-no-missing-blank-lines": "^1.0.0", - "remark-lint-no-multiple-toplevel-headings": "^1.0.0", - "remark-lint-no-paragraph-content-indent": "^1.0.1", - "remark-lint-no-reference-like-url": "^1.0.0", - "remark-lint-no-shell-dollars": "^1.0.0", - "remark-lint-no-shortcut-reference-image": "^1.0.0", - "remark-lint-no-shortcut-reference-link": "^1.0.1", - "remark-lint-no-table-indentation": "^1.0.0", - "remark-lint-no-tabs": "^1.0.0", - "remark-lint-no-trailing-spaces": "^3.0.2", - "remark-lint-no-undefined-references": "^1.0.0", - "remark-lint-no-unused-definitions": "^1.0.0", - "remark-lint-ordered-list-marker-style": "^1.0.0", - "remark-lint-ordered-list-marker-value": "^1.0.0", - "remark-lint-rule-style": "^1.0.0", - "remark-lint-strong-marker": "^1.0.0", - "remark-lint-table-cell-padding": "^1.0.0", - "remark-lint-table-pipe-alignment": "^1.0.0", - "remark-lint-table-pipes": "^1.0.0", - "remark-lint-unordered-list-marker-style": "^1.0.0", - "remark-slug": "^5.0.0", - "remark-unlink": "^2.0.0", - "remark-validate-links": "^9.0.1", - "remark-vdom": "^8.0.0", - "semver": "^6.0.0", - "source-map-explorer": "^2.5.3", - "spdx-license-ids": "^3.0.0", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "tap-spec": "5.x.x", - "tap-summary": "^4.0.0", - "tap-xunit": "^2.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "to-vfile": "^6.0.0", - "typedoc": "git+https://github.com/kgryte/typedoc.git#0.16.11-patch", - "typescript": "4.3.5", - "uglify-js": "^3.17.4", - "uglifyify": "^5.0.0", - "unified-lint-rule": "^1.0.1", - "unist-util-visit": "^2.0.0", - "unist-util-visit-parents": "^3.1.1", - "yaml": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdlib-js", - "stdlib.js", - "js-stdlib", - "stdlibjs", - "standard", - "std", - "library", - "lib", - "libstd", - "numerical", - "numeric", - "mathematical", - "mathematics", - "math", - "scientific", - "machine learning", - "machine-learning", - "ml", - "ndarray", - "numpy", - "scipy" - ] -} From 036f1173a0cefea75acbf147f3aad98396c5b36a Mon Sep 17 00:00:00 2001 From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com> Date: Mon, 31 Mar 2025 14:43:54 +0530 Subject: [PATCH 03/19] Delete .gitignore Signed-off-by: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com> --- .gitignore | 197 ----------------------------------------------------- 1 file changed, 197 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 999c7c418f51..000000000000 --- a/.gitignore +++ /dev/null @@ -1,197 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Files # -######### -package.json.copy -.stdlibrc - -# Directories # -############### -build/ -downloads/ -reports/ -tmp/ - -# Compiled source # -################### -*.com -*.class -*.dll -*.o -*.so -*.slo -*.lo -*.obj -*.dylib -*.lai -*.la -*.a -*.lib -*.ko -*.elf -*.node - -# Precompiled headers # -####################### -*.gch -*.pch - -# Executables # -############### -*.exe -*.out -*.app - -# Packages # -############ -# It is better to unpack these files and commit the raw source -# git has its own built in compression methods -*.7z -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip - -# Logs and databases # -###################### -*.log -*.sql -*.sqlite - -# OS generated files # -###################### -.DS_Store -.DS_Store? -._* -.Spotlight-V100 -.Trashes -Icon? -ehthumbs.db -Thumbs.db -Desktop.ini - -# Temporary files # -################### -*~ - -# Node.js # -########### -/node_modules/ -lib/node_modules/**/node_modules/ -docs/**/node_modules/ -pids -*.pid -*.seed -yarn.lock -package-lock.json - -# Typescript # -############## -*.tsbuildinfo -lib/node_modules/**/tsconfig.json -lib/node_modules/**/tslint.json - -# Matlab # -########## -*.asv -*.mex* - -# Fortran # -########### -*.mod - -# R # -##### -.Rhistory -.Rapp.history -.Rproj.user/ - -# Python # -########## -__pycache__/ -*.py[cod] -*$py.class -*.egg-info/ - -# TeX # -####### -*.aux -*.lof -*.log -*.lot -*.fls -*.out -*.toc -*.dvi -*-converted-to.* -*.bbl -*.bcf -*.blg -*-blx.aux -*-blx.bib -*.brf -*.run.xml -*.fdb_latexmk -*.synctex -*.synctex.gz -*.synctex.gz(busy) -*.pdfsync -*.alg -*.loa -acs-*.bib -*.thm -*.nav -*.snm -*.vrb -*.acn -*.acr -*.glg -*.glo -*.gls -*-concordance.tex -*.tikz -*-tikzDictionary -*.idx -*.ilg -*.ind -*.ist - -# Visual Studio # -################# -.vscode/ -jsconfig.json - -# Sublime Text # -################ -*.sublime-workspace -*.sublime-project - -# Other editor files # -###################### -.idea/ - -# Cursor # -########## -.cursorignore -package.json -etc/npm/deps.txt -etc/npm/deps.txt From b97382b34455e1260da992a57e10dead5ea2ab17 Mon Sep 17 00:00:00 2001 From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com> Date: Mon, 31 Mar 2025 14:51:45 +0530 Subject: [PATCH 04/19] update package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 1ca451cfbe4d..6f1759faad64 100644 --- a/package.json +++ b/package.json @@ -293,3 +293,4 @@ "scipy" ] } + From 732c761586210c3ccc9eb82f1478ea495ed52450 Mon Sep 17 00:00:00 2001 From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com> Date: Mon, 31 Mar 2025 15:05:09 +0530 Subject: [PATCH 05/19] Create .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..3c3629e647f5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules From cc378e3959107bbadce0f57cc1f836c706807e7b Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 7 Jun 2025 13:08:19 +0000 Subject: [PATCH 06/19] fix: add .gitignore file --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .gitignore | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 194 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3c3629e647f5..16b03f7702dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,194 @@ -node_modules +#/ +# @license Apache-2.0 +# +# Copyright (c) 2017 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. +#/ + +# Files # +######### +package.json.copy +.stdlibrc + +# Directories # +############### +build/ +downloads/ +reports/ +tmp/ + +# Compiled source # +################### +*.com +*.class +*.dll +*.o +*.so +*.slo +*.lo +*.obj +*.dylib +*.lai +*.la +*.a +*.lib +*.ko +*.elf +*.node + +# Precompiled headers # +####################### +*.gch +*.pch + +# Executables # +############### +*.exe +*.out +*.app + +# Packages # +############ +# It is better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Logs and databases # +###################### +*.log +*.sql +*.sqlite + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +Icon? +ehthumbs.db +Thumbs.db +Desktop.ini + +# Temporary files # +################### +*~ + +# Node.js # +########### +/node_modules/ +lib/node_modules/**/node_modules/ +docs/**/node_modules/ +pids +*.pid +*.seed +yarn.lock +package-lock.json + +# Typescript # +############## +*.tsbuildinfo +lib/node_modules/**/tsconfig.json +lib/node_modules/**/tslint.json + +# Matlab # +########## +*.asv +*.mex* + +# Fortran # +########### +*.mod + +# R # +##### +.Rhistory +.Rapp.history +.Rproj.user/ + +# Python # +########## +__pycache__/ +*.py[cod] +*$py.class +*.egg-info/ + +# TeX # +####### +*.aux +*.lof +*.log +*.lot +*.fls +*.out +*.toc +*.dvi +*-converted-to.* +*.bbl +*.bcf +*.blg +*-blx.aux +*-blx.bib +*.brf +*.run.xml +*.fdb_latexmk +*.synctex +*.synctex.gz +*.synctex.gz(busy) +*.pdfsync +*.alg +*.loa +acs-*.bib +*.thm +*.nav +*.snm +*.vrb +*.acn +*.acr +*.glg +*.glo +*.gls +*-concordance.tex +*.tikz +*-tikzDictionary +*.idx +*.ilg +*.ind +*.ist + +# Visual Studio # +################# +.vscode/ +jsconfig.json + +# Sublime Text # +################ +*.sublime-workspace +*.sublime-project + +# Other editor files # +###################### +.idea/ + +# Cursor # +########## +.cursorignore From bebc5974da06a724d02665c62993b37c3cf8bd1c Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 7 Jun 2025 13:16:11 +0000 Subject: [PATCH 07/19] fix: package.json file --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - 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 --- --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f1759faad64..2134c10bdb85 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "directories": { "doc": "./docs", "example": "./examples", - "lib": "./lib" + "lib": "./lib", + "test": "./test" }, "types": "./docs/types", "scripts": { From 4de228db35dd44c1a97be5c1a4affe67c6c0a5ce Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 7 Jun 2025 14:58:06 +0000 Subject: [PATCH 08/19] fix: benchmark files --- .../base/nanmin-by/benchmark/benchmark.js | 20 ++++++++++++------- .../nanmin-by/benchmark/benchmark.ndarray.js | 16 ++++++++++----- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js index d15658068a91..5e1a84261697 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ var bernoulli = require( '@stdlib/random/base/bernoulli' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; -var nanminBy = require( './../lib/nanmin_by.js' ); +var nanminBy = require( './../lib/main.js' ); // FUNCTIONS // @@ -39,17 +39,23 @@ var nanminBy = require( './../lib/nanmin_by.js' ); * @param {number} value - array element * @returns {number} accessed value */ +function accessor( value ) { + return value * 2.0; +} + +/** +* Returns a random number. +* +* @private +* @returns {number} random number +*/ function rand() { - if( bernoulli( 0.8 ) < 1 ) { + if ( bernoulli( 0.8 ) < 1 ) { return NaN; } return uniform( -50.0, 50.0 ); } -function accessor( value ) { - return value * 2.0; -} - /** * Create a benchmark function. * diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js index 55896f5eaf03..50bc47cefb81 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js @@ -39,17 +39,23 @@ var nanminBy = require( './../lib/ndarray.js' ); * @param {number} value - array element * @returns {number} accessed value */ +function accessor( value ) { + return value * 2.0; +} + +/** +* Returns a random number. +* +* @private +* @returns {number} random number +*/ function rand() { - if( bernoulli( 0.8 ) < 1 ) { + if ( bernoulli( 0.8 ) < 1 ) { return NaN; } return uniform( -50.0, 50.0 ); } -function accessor( value ) { - return value * 2.0; -} - /** * Create a benchmark function. * From dc33f206d1ddcd7ec67cdaa7f8306ccba0e6a74a Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 7 Jun 2025 15:02:40 +0000 Subject: [PATCH 09/19] fix: repl file --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../stats/base/nanmin-by/docs/repl.txt | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt index 9938bec9e8e5..9d1fd1c4961e 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt @@ -1,10 +1,10 @@ {{alias}}( N, x, strideX, clbk[, thisArg] ) - Calculates the minimum value of a strided array via a callback function, + Computes the minimum value of a strided array via a callback function, ignoring `NaN` values. - The `N` and `strideX` parameters determine which elements in `x` are accessed - at runtime. + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -35,7 +35,7 @@ like (excluding strings and functions). strideX: integer - Index increment for `x`. + Stride length. clbk: Function Callback function. @@ -56,25 +56,24 @@ > {{alias}}( x.length, x, 1, accessor ) -10.0 - // Using `N` and `strideX` parameters: + // Using `N` and stride parameters: > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, NaN, -3.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, x, 2, accessor ) + > {{alias}}( 4, x, 2, accessor ) -4.0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > {{alias}}( N, x1, 2, accessor ) + > {{alias}}( 3, x1, 2, accessor ) -12.0 + {{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] ) - Calculates the minimum value of a strided array via a callback function, + Computes the minimum value of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the `offsetX` parameter supports indexing semantics based on a + buffer, the offset parameter supports indexing semantics based on a starting index. Parameters @@ -87,7 +86,7 @@ like (excluding strings and functions). strideX: integer - Index increment for `x`. + Stride length. offsetX: integer Starting index of `x`. @@ -113,8 +112,7 @@ // Using an index offset: > x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1, accessor ) + > {{alias}}.ndarray( 3, x, 2, 1, accessor ) -12.0 See Also From 2a202576a470e107e123c7cd4fe619f3420c3a95 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 7 Jun 2025 15:09:51 +0000 Subject: [PATCH 10/19] docs: update docs --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../base/nanmin-by/docs/types/index.d.ts | 17 ++++++++------- .../stats/base/nanmin-by/docs/types/test.ts | 21 ++++++++++++------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/index.d.ts index a61b8c56b344..1bf3d9765d3e 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ /// import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; + /** * Input array. */ @@ -55,7 +56,7 @@ type Binary = ( this: U, value: T, aidx: number ) => number | void; * * @param value - array element * @param aidx - array index -* @param sidx - strided index (offsetX + aidx*strideX) +* @param sidx - strided index (offset + aidx*stride) * @returns accessed value */ type Ternary = ( this: U, value: T, aidx: number, sidx: number ) => number | void; @@ -65,7 +66,7 @@ type Ternary = ( this: U, value: T, aidx: number, sidx: number ) => number * * @param value - array element * @param aidx - array index -* @param sidx - strided index (offsetX + aidx*strideX) +* @param sidx - strided index (offset + aidx*stride) * @param array - input array * @returns accessed value */ @@ -87,7 +88,7 @@ type Callback = Nullary | Unary | Binary | Ternary | */ interface Routine { /** - * Calculates the minimum value of a strided array via a callback function, ignoring `NaN` values. + * Computes the minimum value of a strided array via a callback function, ignoring `NaN` values. * * ## Notes * @@ -121,10 +122,10 @@ interface Routine { * var v = nanminBy( x.length, x, 1, accessor ); * // returns -10.0 */ - ( N: number, x: InputArray, stride: number, clbk: Callback, thisArg?: ThisParameterType> ): number; + ( N: number, x: InputArray, strideX: number, clbk: Callback, thisArg?: ThisParameterType> ): number; /** - * Calculates the minimum value of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics. + * Computes the minimum value of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics. * * ## Notes * @@ -163,7 +164,7 @@ interface Routine { } /** -* Calculates the minimum value of a strided array via a callback function, ignoring `NaN` values. +* Computes the minimum value of a strided array via a callback function, ignoring `NaN` values. * * ## Notes * @@ -171,7 +172,7 @@ interface Routine { * * - `value`: array element * - `aidx`: array index -* - `sidx`: strided index (offsetX + aidx*strideX) +* - `sidx`: strided index (offset + aidx*stride) * - `array`: input array * * - The callback function should return a numeric value. diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/test.ts index 5fd3c233c106..8c4008fd3652 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,8 @@ * limitations under the License. */ -import toAccessorArray from '@stdlib/array/base/to-accessor-array'; -import nanminBy = require( './index' ); import AccessorArray = require( '@stdlib/array/base/accessor' ); +import nanminBy = require( './index' ); const accessor = (): number => { return 5.0; @@ -31,8 +30,11 @@ const accessor = (): number => { { const x = new Float64Array( 10 ); - nanminBy( x.length, toAccessorArray( x ), 1, accessor ); // $ExpectType number - nanminBy( x.length, toAccessorArray( x ), 1, accessor, {} ); // $ExpectType number + nanminBy( x.length, x, 1, accessor ); // $ExpectType number + nanminBy( x.length, new AccessorArray( x ), 1, accessor ); // $ExpectType number + + nanminBy( x.length, x, 1, accessor, {} ); // $ExpectType number + nanminBy( x.length, new AccessorArray( x ), 1, accessor, {} ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -72,7 +74,7 @@ const accessor = (): number => { nanminBy( x.length, x, undefined, accessor ); // $ExpectError nanminBy( x.length, x, [], accessor ); // $ExpectError nanminBy( x.length, x, {}, accessor ); // $ExpectError - nanminBy( x.length, x, ( x: number, accessor ): number => x, accessor ); // $ExpectError + nanminBy( x.length, x, ( x: number ): number => x, accessor ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a function... @@ -103,8 +105,11 @@ const accessor = (): number => { { const x = new Float64Array( 10 ); - nanminBy.ndarray( x.length, toAccessorArray( x ), 1, 0, accessor ); // $ExpectType number - nanminBy.ndarray( x.length, toAccessorArray( x ), 1, 0, accessor, {} ); // $ExpectType number + nanminBy.ndarray( x.length, x, 1, 0, accessor ); // $ExpectType number + nanminBy.ndarray( x.length, new AccessorArray( x ), 1, 0, accessor ); // $ExpectType number + + nanminBy.ndarray( x.length, x, 1, 0, accessor, {} ); // $ExpectType number + nanminBy.ndarray( x.length, new AccessorArray( x ), 1, 0, accessor, {} ); // $ExpectType number } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... From 78846cb33cc8703d186d32b3cf447add0cc0076e Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 7 Jun 2025 15:14:58 +0000 Subject: [PATCH 11/19] fix: update docs and examples --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: 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 --- --- .../stats/base/nanmin-by/benchmark/benchmark.ndarray.js | 4 ++-- .../@stdlib/stats/base/nanmin-by/examples/index.js | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js index 50bc47cefb81..a1a217f00e3f 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ function rand() { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, "float64", rand ); + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/examples/index.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/examples/index.js index d4ef47ef0e19..a1bc1d6a611f 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,17 +18,16 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var uniform = require( '@stdlib/random/base/uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var bernoulli = require( '@stdlib/random/base/bernoulli' ); var nanminBy = require( './../lib' ); function rand() { - if ( bernoulli( 0.8 ) < 1 ) { + if ( bernoulli( 0.8 )< 0.2 ) { return NaN; } - return uniform( -50.0, 50.0 ); + return uniform( -50, 50 ); } function accessor( v ) { From 5bfda32a14a37cabd786e4725a2a9d406eb7a224 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 7 Jun 2025 15:30:27 +0000 Subject: [PATCH 12/19] fix: implementation --- 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 --- --- .../stats/base/nanmin-by/lib/accessors.js | 55 ++++++++++--------- .../@stdlib/stats/base/nanmin-by/lib/index.js | 9 ++- .../@stdlib/stats/base/nanmin-by/lib/main.js | 27 ++++++++- .../stats/base/nanmin-by/lib/nanmin_by.js | 55 ------------------- .../stats/base/nanmin-by/lib/ndarray.js | 8 +-- 5 files changed, 66 insertions(+), 88 deletions(-) delete mode 100644 lib/node_modules/@stdlib/stats/base/nanmin-by/lib/nanmin_by.js diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js index 5c8b03088e2e..74b698cfb7aa 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js @@ -27,30 +27,34 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); // MAIN // /** -* Calculates the minimum value of a strided array via a callback function, ignoring `NaN` values. +* Computes the minimum value of a strided array via a callback function, ignoring `NaN` values. * * @param {PositiveInteger} N - number of indexed elements -* @param {Collection} x - input array/collection -* @param {integer} strideX - index increment +* @param {Object} x - input array object +* @param {Collection} x.data - input array data +* @param {Array} x.accessors - array element accessors +* @param {integer} strideX - stride length * @param {NonNegativeInteger} offsetX - starting index * @param {Callback} clbk - callback * @param {*} [thisArg] - execution context * @returns {number} minimum value * * @example -* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ]; +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = toAccessorArray( [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ] ); * * function accessor( v ) { * return v * 2.0; * } * -* var v = nanminBy( x.length, x, 1, 0, accessor ); +* var v = nanminBy( x.length, arraylike2object( x ), 1, 0, accessor ); * // returns -10.0 */ function nanminBy( N, x, strideX, offsetX, clbk, thisArg ) { var xbuf; var get; - var max; var min; var ix; var v; @@ -61,35 +65,36 @@ function nanminBy( N, x, strideX, offsetX, clbk, thisArg ) { // Cache a reference to the element accessor: get = x.accessors[0]; + if ( N <= 0 ) { - return NaN; + return NaN; } if ( N === 1 || strideX === 0 ) { - v = clbk.call( thisArg, get( xbuf, 0 ), 0, 0, x ); - if ( v === void 0 || isnan( v ) ) { - return NaN; - } - return v; + v = clbk.call( thisArg, get( xbuf, offsetX ), 0, offsetX, x ); + if ( v === void 0 || isnan( v ) ) { + return NaN; + } + return v; } ix = offsetX; for ( i = 0; i < N; i++ ) { - min = clbk.call( thisArg, get( xbuf, ix ), i, ix, x ); - if ( min === min && min !== void 0 ) { - break; - } - ix += strideX; + min = clbk.call( thisArg, get( xbuf, ix ), i, ix, xbuf ); + if ( min === min && min !== void 0 ) { + break; + } + ix += strideX; } if ( i === N ) { - return NaN; + return NaN; } i += 1; - for( i ; i < N ; i++ ) { + for ( i; i < N; i++ ) { ix += strideX; - v = clbk.call( thisArg, get( xbuf, ix ), i, ix, x ); - if ( v === void 0 || isnan( v ) ) { - continue; - } - if( v < min || ( v === min && isNegativeZero( v ) ) ) { + v = clbk.call( thisArg, get( xbuf, ix ), i, ix, xbuf ); + if ( v === void 0 || isnan( v ) ) { + continue; + } + if ( v < min || ( v === min && isNegativeZero( v ) ) ) { min = v; } } @@ -99,4 +104,4 @@ function nanminBy( N, x, strideX, offsetX, clbk, thisArg ) { // EXPORTS // -module.exports = nanminBy; \ No newline at end of file +module.exports = nanminBy; diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/index.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/index.js index 467a89cf670e..d47bc104369b 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Calculate the minimum value of a strided array via a callback function and ignoring `NaN` values. +* Compute the minimum value of a strided array via a callback function and ignoring `NaN` values. * * @module @stdlib/stats/base/nanmin-by * @@ -50,7 +50,14 @@ // MODULES // +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); var main = require( './main.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/main.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/main.js index 360b050b4a6b..a9bf0ef9e62d 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/main.js @@ -20,14 +20,35 @@ // MODULES // -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var nanminBy = require( './nanmin_by.js' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); var ndarray = require( './ndarray.js' ); // MAIN // -setReadOnly( nanminBy, 'ndarray', ndarray ); +/** +* Computes the minimum value of a strided array via a callback function, ignoring `NaN` values. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Collection} x - input array/collection +* @param {integer} strideX - index increment +* @param {Callback} clbk - callback +* @param {*} [thisArg] - execution context +* @returns {number} minimum value +* +* @example +* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ]; +* +* function accessor( v ) { +* return v * 2.0; +* } +* +* var v = nanminBy( x.length, x, 1, accessor ); +* // returns -10.0 +*/ +function nanminBy( N, x, strideX, clbk, thisArg ) { + return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg ); +} // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/nanmin_by.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/nanmin_by.js deleted file mode 100644 index bf097f60d678..000000000000 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/nanmin_by.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var stride2offset = require( '@stdlib/strided/base/stride2offset' ); -var ndarray = require( './ndarray.js' ); - -// MAIN // - -/** -* Calculates the minimum value of a strided array via a callback function, ignoring `NaN` values. -* -* @param {PositiveInteger} N - number of indexed elements -* @param {Collection} x - input array/collection -* @param {integer} strideX - index increment -* @param {Callback} clbk - callback -* @param {*} [thisArg] - execution context -* @returns {number} minimum value -* -* @example -* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ]; -* -* function accessor( v ) { -* return v * 2.0; -* } -* -* var v = nanminBy( x.length, x, 1, accessor ); -* // returns -10.0 -*/ -function nanminBy( N, x, strideX, clbk, thisArg ) { - return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk , thisArg ); -} - - -// EXPORTS // - -module.exports = nanminBy; diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/ndarray.js index 41dbf3fc2f98..64c2f5f21a96 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ var accessors = require( './accessors.js' ); // MAIN // /** -* Calculates the minimum value of a strided array via a callback function, ignoring `NaN` values. +* Computes the minimum value of a strided array via a callback function, ignoring `NaN` values. * * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array/collection @@ -60,11 +60,11 @@ function nanminBy( N, x, strideX, offsetX, clbk, thisArg ) { return NaN; } o = arraylike2object( x ); - if( o.accessorProtocol ) { + if ( o.accessorProtocol ) { return accessors( N, o, strideX, offsetX, clbk, thisArg ); } if ( N === 1 || strideX === 0 ) { - v = clbk.call( thisArg, x[ 0 ], 0, 0, x ); + v = clbk.call( thisArg, x[ offsetX ], 0, offsetX, x ); if ( v === void 0 ) { return NaN; } From df82ec073ec3acf9795e9175108883d12f3e6cc9 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 7 Jun 2025 15:31:39 +0000 Subject: [PATCH 13/19] chore: minor cleanups --- 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: passed - 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 --- --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 2134c10bdb85..25b79ee80bb9 100644 --- a/package.json +++ b/package.json @@ -294,4 +294,3 @@ "scipy" ] } - From 101df0207feb13c1142f535c46574fe43a7d09c6 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 7 Jun 2025 15:35:20 +0000 Subject: [PATCH 14/19] fix: update README --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/nanmin-by/README.md | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/README.md b/lib/node_modules/@stdlib/stats/base/nanmin-by/README.md index 7d069fa601b1..c165a3251d48 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/README.md +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2025 The Stdlib Authors. +Copyright (c) 2020 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ var nanminBy = require( '@stdlib/stats/base/nanmin-by' ); #### nanminBy( N, x, strideX, clbk\[, thisArg] ) -Calculates the minimum value of strided array `x` via a callback function, ignoring `NaN` values. +Computes the minimum value of a strided array via a callback function, ignoring `NaN` values. ```javascript function accessor( v ) { @@ -49,7 +49,7 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions). -- **strideX**: index increment. +- **strideX**: stride length. - **clbk**: callback function. - **thisArg**: execution context (_optional_). @@ -81,19 +81,16 @@ var cnt = context.count; // returns 10 ``` -The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element ```javascript -var floor = require( '@stdlib/math/base/special/floor' ); - function accessor( v ) { return v * 2.0; } var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0, NaN, NaN ]; -var N = floor( x.length / 2 ); -var v = nanminBy( N, x, 2, accessor ); +var v = nanminBy( 5, x, 2, accessor ); // returns -4.0 ``` @@ -101,7 +98,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); function accessor( v ) { return v * 2.0; @@ -112,16 +108,15 @@ var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); // Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length/2 ); // Access every other element... -var v = nanminBy( N, x1, 2, accessor ); +var v = nanminBy( 3, x1, 2, accessor ); // returns -12.0 ``` #### nanminBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] ) -Calculates the minimum value of strided array `x` via a callback function, ignoring `NaN` values and using alternative indexing semantics. +Computes the minimum value of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics. ```javascript function accessor( v ) { @@ -138,7 +133,7 @@ The function has the following additional parameters: - **offsetX**: starting index. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offsetX` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x` +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x` ```javascript function accessor( v ) { @@ -183,10 +178,10 @@ var bernoulli = require( '@stdlib/random/base/bernoulli' ); var nanminBy = require( '@stdlib/stats/base/nanmin-by' ); function rand() { - if( bernoulli( 0.8 ) < 1 ) { + if ( bernoulli( 0.8 )< 0.2 ) { return NaN; } - return uniform( -50.0, 50.0 ); + return uniform( -50, 50 ); } function accessor( v ) { @@ -230,6 +225,8 @@ console.log( v ); [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray +[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor + [@stdlib/stats/strided/dnanmin]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/dnanmin From 3aa71c32308e47652293a127e6cfef8c32a34609 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 7 Jun 2025 15:49:28 +0000 Subject: [PATCH 15/19] test: add accessor array tests --- 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 --- --- .../base/nanmin-by/test/test.nanmin_by.js | 51 +++++++------------ .../stats/base/nanmin-by/test/test.ndarray.js | 38 +++++--------- 2 files changed, 33 insertions(+), 56 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.nanmin_by.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.nanmin_by.js index 03b46670bc05..3c910b9c1a6d 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.nanmin_by.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.nanmin_by.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,12 +21,11 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var Float64Array = require( '@stdlib/array/float64' ); -var nanminBy = require( './../lib/nanmin_by.js' ); +var nanminBy = require( './../lib/main.js' ); // FUNCTIONS // @@ -76,11 +75,11 @@ tape( 'the function calculates the minimum value of a strided array via a callba v = nanminBy( x.length, x, 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( x.length, x, 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array x[ 2 ] = 1.0; v = nanminBy( x.length, x, 1, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); @@ -112,13 +111,13 @@ tape( 'the function calculates the minimum value of a strided array via a callba v = nanminBy( x.length, toAccessorArray( x ), 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( x.length, toAccessorArray( x ), 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array x[ 2 ] = 1.0; - v = nanminBy( x.length, toAccessorArray( x), 1, accessor ); + v = nanminBy( x.length, toAccessorArray( x ), 1, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); t.end(); @@ -148,7 +147,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu v = nanminBy( 0, toAccessorArray( x ), 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - v = nanminBy( -1, x, 1, accessor ); + v = nanminBy( -1, toAccessorArray( x ), 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -163,7 +162,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first v = nanminBy( 1, x, 1, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( 1, x, 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -179,7 +178,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first v = nanminBy( 1, toAccessorArray( x ), 1, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( 1, toAccessorArray( x ), 1, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -187,7 +186,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -204,15 +202,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN ]; - N = floor( x.length / 2 ); - v = nanminBy( N, x, 2, accessor ); + v = nanminBy( 5, x, 2, accessor ); t.strictEqual( v, -4.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a `stride` parameter (accessors)', function test( t ) { - var N; var x; var v; @@ -229,15 +225,13 @@ tape( 'the function supports a `stride` parameter (accessors)', function test( t NaN ]; - N = floor( x.length / 2 ); - v = nanminBy( N, toAccessorArray( x ), 2, accessor ); + v = nanminBy( 5, toAccessorArray( x ), 2, accessor ); t.strictEqual( v, -4.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -254,15 +248,13 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - N = floor( x.length / 2 ); - v = nanminBy( N, x, -2, accessor ); + v = nanminBy( 5, x, -2, accessor ); t.strictEqual( v, -4.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) { - var N; var x; var v; @@ -279,8 +271,7 @@ tape( 'the function supports a negative `stride` parameter (accessors)', functio 2.0 ]; - N = floor( x.length / 2 ); - v = nanminBy( N, toAccessorArray( x ), -2, accessor ); + v = nanminBy( 5, toAccessorArray( x ), -2, accessor ); t.strictEqual( v, -4.0, 'returns expected value' ); t.end(); @@ -295,7 +286,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f v = nanminBy( x.length, x, 0, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( 1, x, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -311,7 +302,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f v = nanminBy( x.length, toAccessorArray( x ), 0, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( 1, toAccessorArray( x ), 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -321,7 +312,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([ @@ -339,9 +329,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = nanminBy( N, x1, 2, accessor ); + v = nanminBy( 5, x1, 2, accessor ); t.strictEqual( v, -4.0, 'returns expected value' ); t.end(); @@ -350,7 +339,6 @@ tape( 'the function supports view offsets', function test( t ) { tape( 'the function supports view offsets (accessors)', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -368,9 +356,8 @@ tape( 'the function supports view offsets (accessors)', function test( t ) { ]); x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = nanminBy( N, toAccessorArray( x1 ), 2, accessor ); + v = nanminBy( 5, toAccessorArray( x1 ), 2, accessor ); t.strictEqual( v, -4.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.ndarray.js index 8ca59b2ad523..efe679230bd2 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +21,9 @@ // 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 isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var nanminBy = require( './../lib/ndarray.js' ); @@ -75,11 +74,11 @@ tape( 'the function calculates the minimum value of a strided array via a callba v = nanminBy( x.length, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( x.length, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array x[ 2 ] = 1.0; v = nanminBy( x.length, x, 1, 0, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); @@ -111,11 +110,11 @@ tape( 'the function calculates the minimum value of a strided array via a callba v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Array( 5 ); // sparse array + x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array x[ 2 ] = 1.0; v = nanminBy( x.length, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); @@ -162,7 +161,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first v = nanminBy( 1, x, 1, 0, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( 1, x, 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -178,7 +177,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first v = nanminBy( 1, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( 1, toAccessorArray( x ), 1, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); @@ -186,7 +185,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -203,15 +201,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN ]; - N = floor( x.length / 2 ); - v = nanminBy( N, x, 2, 0, accessor ); + v = nanminBy( 5, x, 2, 0, accessor ); t.strictEqual( v, -4.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a `stride` parameter (accessors)', function test( t ) { - var N; var x; var v; @@ -228,15 +224,13 @@ tape( 'the function supports a `stride` parameter (accessors)', function test( t NaN ]; - N = floor( x.length / 2 ); - v = nanminBy( N, toAccessorArray( x ), 2, 0, accessor ); + v = nanminBy( 5, toAccessorArray( x ), 2, 0, accessor ); t.strictEqual( v, -4.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -253,15 +247,13 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - N = floor( x.length / 2 ); - v = nanminBy( N, x, -2, 8, accessor ); + v = nanminBy( 5, x, -2, 8, accessor ); t.strictEqual( v, -4.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) { - var N; var x; var v; @@ -278,8 +270,7 @@ tape( 'the function supports a negative `stride` parameter (accessors)', functio 2.0 ]; - N = floor( x.length / 2 ); - v = nanminBy( N, toAccessorArray( x ), -2, 8, accessor ); + v = nanminBy( 5, toAccessorArray( x ), -2, 8, accessor ); t.strictEqual( v, -4.0, 'returns expected value' ); t.end(); @@ -294,13 +285,12 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f v = nanminBy( x.length, x, 0, 0, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( 1, x, 0, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); - tape( 'if provided a `stride` parameter equal to `0`, the function returns the first accessed element (accessors)', function test( t ) { var x; var v; @@ -310,7 +300,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f v = nanminBy( x.length, toAccessorArray( x ), 0, 0, accessor ); t.strictEqual( v, 2.0, 'returns expected value' ); - x = new Array( 1 ); // sparse array + x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array v = nanminBy( 1, toAccessorArray( x ), 0, 0, accessor ); t.strictEqual( isnan( v ), true, 'returns expected value' ); From 34ba32f135d2551aac3f73be6677ef72a3e6fcac Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 7 Jun 2025 15:53:23 +0000 Subject: [PATCH 16/19] chore: minor cleanup --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/nanmin-by/benchmark/benchmark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js index 5e1a84261697..8078111657e3 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js @@ -64,7 +64,7 @@ function rand() { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, "float64", rand ); + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { From 3637e7a3761dfb20a600d001bebe76e5d13568f1 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 7 Jun 2025 13:06:22 -0700 Subject: [PATCH 17/19] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/stats/base/nanmin-by/benchmark/benchmark.js | 2 +- .../@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js index 8078111657e3..dd58af109323 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.js @@ -64,7 +64,7 @@ function rand() { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'float64', rand ); + var x = filledarrayBy( len, 'generic', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js index a1a217f00e3f..6567d1764513 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/benchmark/benchmark.ndarray.js @@ -64,7 +64,7 @@ function rand() { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = filledarrayBy( len, 'float64', rand ); + var x = filledarrayBy( len, 'generic', rand ); return benchmark; function benchmark( b ) { From 7bea868123e24afa39eb9b7407a53ee8758634e7 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 7 Jun 2025 13:09:37 -0700 Subject: [PATCH 18/19] docs: fix note Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt index 9d1fd1c4961e..022002e0f289 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/docs/repl.txt @@ -9,7 +9,7 @@ Indexing is relative to the first index. To introduce an offset, use typed array views. - If `N <= 0`, the function returns `x` unchanged. + If `N <= 0`, the function returns `NaN`. The callback function is provided four arguments: From f71ef5e10debaccfad8c17fabcbc473a0865831d Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 7 Jun 2025 13:11:47 -0700 Subject: [PATCH 19/19] refactor: remove unreachable code path Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js index 74b698cfb7aa..cd99cdc76f77 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js +++ b/lib/node_modules/@stdlib/stats/base/nanmin-by/lib/accessors.js @@ -66,9 +66,6 @@ function nanminBy( N, x, strideX, offsetX, clbk, thisArg ) { // Cache a reference to the element accessor: get = x.accessors[0]; - if ( N <= 0 ) { - return NaN; - } if ( N === 1 || strideX === 0 ) { v = clbk.call( thisArg, get( xbuf, offsetX ), 0, offsetX, x ); if ( v === void 0 || isnan( v ) ) {