From 3081c131f6b90403e2151f1e8b428dabce0b87ed Mon Sep 17 00:00:00 2001 From: aayush0325 Date: Sat, 8 Feb 2025 05:19:07 +0000 Subject: [PATCH 1/3] refactor: update stats/base/nanmax to follow latest project conventions --- 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/nanmax/README.md | 54 +++++------ .../stats/base/nanmax/benchmark/benchmark.js | 31 ++++--- .../nanmax/benchmark/benchmark.ndarray.js | 29 +++--- .../@stdlib/stats/base/nanmax/docs/repl.txt | 32 +++---- .../stats/base/nanmax/docs/types/index.d.ts | 12 +-- .../stats/base/nanmax/examples/index.js | 21 ++--- .../@stdlib/stats/base/nanmax/lib/index.js | 14 +-- .../@stdlib/stats/base/nanmax/lib/main.js | 21 ++++- .../@stdlib/stats/base/nanmax/lib/nanmax.js | 89 ------------------- .../@stdlib/stats/base/nanmax/lib/ndarray.js | 21 ++--- .../test/{test.nanmax.js => test.main.js} | 15 +--- .../stats/base/nanmax/test/test.ndarray.js | 13 +-- 12 files changed, 127 insertions(+), 225 deletions(-) delete mode 100644 lib/node_modules/@stdlib/stats/base/nanmax/lib/nanmax.js rename lib/node_modules/@stdlib/stats/base/nanmax/test/{test.nanmax.js => test.main.js} (92%) diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/README.md b/lib/node_modules/@stdlib/stats/base/nanmax/README.md index eb9cbf305b1f..0b9d78cb0c55 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/README.md +++ b/lib/node_modules/@stdlib/stats/base/nanmax/README.md @@ -36,15 +36,14 @@ limitations under the License. var nanmax = require( '@stdlib/stats/base/nanmax' ); ``` -#### nanmax( N, x, stride ) +#### nanmax( N, x, strideX ) Computes the maximum value of a strided array `x`, ignoring `NaN` values. ```javascript var x = [ 1.0, -2.0, NaN, 2.0 ]; -var N = x.length; -var v = nanmax( N, x, 1 ); +var v = nanmax( x.length, x, 1 ); // returns 2.0 ``` @@ -52,17 +51,14 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. -- **stride**: index increment for `x`. +- **strideX**: stride length for `x`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the maximum value of every other element in `x`, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the maximum value of every other element in `x`, ```javascript -var floor = require( '@stdlib/math/base/special/floor' ); - var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN, NaN ]; -var N = floor( x.length / 2 ); -var v = nanmax( N, x, 2 ); +var v = nanmax( 5, x, 2 ); // returns 4.0 ``` @@ -72,42 +68,35 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, NaN, NaN, 4.0 ] ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = nanmax( N, x1, 2 ); +var v = nanmax( 4, x1, 2 ); // returns 4.0 ``` -#### nanmax.ndarray( N, x, stride, offset ) +#### nanmax.ndarray( N, x, strideX, offsetX ) Computes the maximum value of a strided array, ignoring `NaN` values and using alternative indexing semantics. ```javascript var x = [ 1.0, -2.0, NaN, 2.0 ]; -var N = x.length; -var v = nanmax.ndarray( N, x, 1, 0 ); +var v = nanmax.ndarray( x.length, x, 1, 0 ); // returns 2.0 ``` The function has the following additional parameters: -- **offset**: starting index for `x`. +- **offsetX**: starting index for `x`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the maximum value for every other value in `x` starting from the second value +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the maximum value for every other element in `x` starting from the second element ```javascript -var floor = require( '@stdlib/math/base/special/floor' ); - var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, NaN, NaN, 2.0, 3.0, 4.0 ]; -var N = floor( x.length / 2 ); -var v = nanmax.ndarray( N, x, 2, 1 ); +var v = nanmax.ndarray( 5, x, 2, 1 ); // returns 4.0 ``` @@ -133,22 +122,19 @@ var v = nanmax.ndarray( N, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var nanmax = require( '@stdlib/stats/base/nanmax' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = round( (randu()*100.0) - 50.0 ); +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { + return NaN; } + return uniform( -50.0, 50.0 ); } + +var x = filledarrayBy( 10, 'float64', rand ); console.log( x ); var v = nanmax( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.js index e4466971f4f7..cd9980ebe20b 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.js @@ -21,15 +21,30 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; -var nanmax = require( './../lib/nanmax.js' ); +var nanmax = require( './../lib/main.js' ); // FUNCTIONS // +/** +* Returns a random value or `NaN`. +* +* @private +* @returns {number} random number or `NaN` +*/ +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { + return NaN; + } + return uniform( -10.0, 10.0 ); +} + /** * Creates a benchmark function. * @@ -38,17 +53,7 @@ var nanmax = require( './../lib/nanmax.js' ); * @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, 'generic', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.ndarray.js index 3aba336dca51..c007f2865581 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.ndarray.js @@ -21,8 +21,10 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; var nanmax = require( './../lib/ndarray.js' ); @@ -30,6 +32,19 @@ var nanmax = require( './../lib/ndarray.js' ); // FUNCTIONS // +/** +* Returns a random value or `NaN`. +* +* @private +* @returns {number} random number or `NaN` +*/ +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { + return NaN; + } + return uniform( -10.0, 10.0 ); +} + /** * Creates a benchmark function. * @@ -38,17 +53,7 @@ var nanmax = require( './../lib/ndarray.js' ); * @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, 'generic', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/nanmax/docs/repl.txt index c2f3a688d01c..bf4a6d75716a 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/nanmax/docs/repl.txt @@ -1,9 +1,9 @@ -{{alias}}( N, x, stride ) +{{alias}}( N, x, strideX ) Computes the maximum value of a strided array, ignoring `NaN` values. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -18,8 +18,8 @@ x: Array|TypedArray Input array. - stride: integer - Index increment. + strideX: integer + Stride length. Returns ------- @@ -33,22 +33,19 @@ > {{alias}}( x.length, x, 1 ) 2.0 - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN, NaN ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > var stride = 2; - > {{alias}}( N, x, stride ) + > {{alias}}( 4, x, 2 ) 2.0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, x1, stride ) + > {{alias}}( 4, x1, 2 ) 2.0 -{{alias}}.ndarray( N, x, stride, offset ) + +{{alias}}.ndarray( N, x, strideX, offsetX ) Computes the maximum value of a strided array, ignoring `NaN` values and using alternative indexing semantics. @@ -64,10 +61,10 @@ x: Array|TypedArray Input array. - stride: integer - Index increment. + strideX: integer + Stride length. - offset: integer + offsetX: integer Starting index. Returns @@ -84,8 +81,7 @@ // Using offset parameter: > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1 ) + > {{alias}}.ndarray( 4, x, 2, 1 ) 2.0 See Also diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/index.d.ts index bb83648e189d..07ffcee11c61 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/index.d.ts @@ -31,7 +31,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length + * @param strideX - stride length * @returns maximum value * * @example @@ -40,15 +40,15 @@ interface Routine { * var v = nanmax( x.length, x, 1 ); * // returns 2.0 */ - ( N: number, x: NumericArray, stride: number ): number; + ( N: number, x: NumericArray, strideX: number ): number; /** * Computes the maximum value of a strided array, ignoring `NaN` values and using alternative indexing semantics. * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length - * @param offset - starting index + * @param strideX - stride length + * @param offsetX - starting index * @returns maximum value * * @example @@ -57,7 +57,7 @@ interface Routine { * var v = nanmax.ndarray( x.length, x, 1, 0 ); * // returns 2.0 */ - ndarray( N: number, x: NumericArray, stride: number, offset: number ): number; + ndarray( N: number, x: NumericArray, strideX: number, offsetX: number ): number; } /** @@ -65,7 +65,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array -* @param stride - stride length +* @param strideX - stride length * @returns maximum value * * @example diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/examples/index.js b/lib/node_modules/@stdlib/stats/base/nanmax/examples/index.js index 76a3d1aa2353..542412ead04d 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/examples/index.js @@ -18,22 +18,19 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var nanmax = require( './../lib' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = round( (randu()*100.0) - 50.0 ); +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { + return NaN; } + return uniform( -50.0, 50.0 ); } + +var x = filledarrayBy( 10, 'float64', rand ); console.log( x ); var v = nanmax( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/lib/index.js b/lib/node_modules/@stdlib/stats/base/nanmax/lib/index.js index 0fa2874244d3..903788a81ae0 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/lib/index.js @@ -27,25 +27,29 @@ * var nanmax = require( '@stdlib/stats/base/nanmax' ); * * var x = [ 1.0, -2.0, NaN, 2.0 ]; -* var N = x.length; * -* var v = nanmax( N, x, 1 ); +* var v = nanmax( x.length, x, 1 ); * // returns 2.0 * * @example -* var floor = require( '@stdlib/math/base/special/floor' ); * var nanmax = require( '@stdlib/stats/base/nanmax' ); * * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ]; -* var N = floor( x.length / 2 ); * -* var v = nanmax.ndarray( N, x, 2, 1 ); +* var v = nanmax.ndarray( 5, x, 2, 1 ); * // returns 4.0 */ // 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/nanmax/lib/main.js b/lib/node_modules/@stdlib/stats/base/nanmax/lib/main.js index b4f536507402..89663ee35aca 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/lib/main.js @@ -20,14 +20,29 @@ // MODULES // -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var nanmax = require( './nanmax.js' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); var ndarray = require( './ndarray.js' ); // MAIN // -setReadOnly( nanmax, 'ndarray', ndarray ); +/** +* Computes the maximum value of a strided array, ignoring `NaN` values. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {NumericArray} x - input array +* @param {integer} strideX - stride length +* @returns {number} maximum value +* +* @example +* var x = [ 1.0, -2.0, NaN, 2.0 ]; +* +* var v = nanmax( x.length, x, 1 ); +* // returns 2.0 +*/ +function nanmax( N, x, strideX ) { + return ndarray( N, x, strideX, stride2offset( N, strideX ) ); +} // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/lib/nanmax.js b/lib/node_modules/@stdlib/stats/base/nanmax/lib/nanmax.js deleted file mode 100644 index 81fe336dbc34..000000000000 --- a/lib/node_modules/@stdlib/stats/base/nanmax/lib/nanmax.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); - - -// MAIN // - -/** -* Computes the maximum value of a strided array, ignoring `NaN` values. -* -* @param {PositiveInteger} N - number of indexed elements -* @param {NumericArray} x - input array -* @param {integer} stride - stride length -* @returns {number} maximum value -* -* @example -* var x = [ 1.0, -2.0, NaN, 2.0 ]; -* var N = x.length; -* -* var v = nanmax( N, x, 1 ); -* // returns 2.0 -*/ -function nanmax( N, x, stride ) { - var max; - var ix; - var v; - var i; - - if ( N <= 0 ) { - return NaN; - } - if ( N === 1 || stride === 0 ) { - return x[ 0 ]; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - for ( i = 0; i < N; i++ ) { - v = x[ ix ]; - if ( v === v ) { - break; - } - ix += stride; - } - if ( i === N ) { - return NaN; - } - max = v; - i += 1; - for ( i; i < N; i++ ) { - ix += stride; - v = x[ ix ]; - if ( isnan( v ) ) { - continue; - } - if ( v > max || ( v === max && isPositiveZero( v ) ) ) { - max = v; - } - } - return max; -} - - -// EXPORTS // - -module.exports = nanmax; diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmax/lib/ndarray.js index 4780748eb72b..1f2f8aa569b6 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/lib/ndarray.js @@ -31,20 +31,17 @@ var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); * * @param {PositiveInteger} N - number of indexed elements * @param {NumericArray} x - input array -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index * @returns {number} maximum value * * @example -* var floor = require( '@stdlib/math/base/special/floor' ); -* * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ]; -* var N = floor( x.length / 2 ); * -* var v = nanmax( N, x, 2, 1 ); +* var v = nanmax( 5, x, 2, 1 ); * // returns 4.0 */ -function nanmax( N, x, stride, offset ) { +function nanmax( N, x, strideX, offsetX ) { var max; var ix; var v; @@ -53,16 +50,16 @@ function nanmax( N, x, stride, offset ) { if ( N <= 0 ) { return NaN; } - if ( N === 1 || stride === 0 ) { - return x[ offset ]; + if ( N === 1 || strideX === 0 ) { + return x[ offsetX ]; } - ix = offset; + ix = offsetX; for ( i = 0; i < N; i++ ) { v = x[ ix ]; if ( v === v ) { break; } - ix += stride; + ix += strideX; } if ( i === N ) { return NaN; @@ -70,7 +67,7 @@ function nanmax( N, x, stride, offset ) { max = v; i += 1; for ( i; i < N; i++ ) { - ix += stride; + ix += strideX; v = x[ ix ]; if ( isnan( v ) ) { continue; diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/test/test.nanmax.js b/lib/node_modules/@stdlib/stats/base/nanmax/test/test.main.js similarity index 92% rename from lib/node_modules/@stdlib/stats/base/nanmax/test/test.nanmax.js rename to lib/node_modules/@stdlib/stats/base/nanmax/test/test.main.js index 6efb4cb92bd0..f4488c886b4e 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/test/test.nanmax.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/test/test.main.js @@ -21,11 +21,10 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var Float64Array = require( '@stdlib/array/float64' ); -var nanmax = require( './../lib/nanmax.js' ); +var nanmax = require( './../lib/main.js' ); // TESTS // @@ -96,7 +95,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; @@ -113,15 +111,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN ]; - N = floor( x.length / 2 ); - v = nanmax( N, x, 2 ); + v = nanmax( 5, x, 2 ); 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; @@ -138,8 +134,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - N = floor( x.length / 2 ); - v = nanmax( N, x, -2 ); + v = nanmax( 5, x, -2 ); t.strictEqual( v, 4.0, 'returns expected value' ); t.end(); @@ -160,7 +155,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([ @@ -178,9 +172,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 = nanmax( N, x1, 2 ); + v = nanmax( 5, x1, 2 ); t.strictEqual( v, 4.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmax/test/test.ndarray.js index 0793a9b6ac91..8b37e605ec07 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var nanmax = require( './../lib/ndarray.js' ); @@ -95,7 +94,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; @@ -112,15 +110,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN ]; - N = floor( x.length / 2 ); - v = nanmax( N, x, 2, 0 ); + v = nanmax( 5, x, 2, 0 ); 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; @@ -137,8 +133,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - N = floor( x.length / 2 ); - v = nanmax( N, x, -2, 8 ); + v = nanmax( 5, x, -2, 8 ); t.strictEqual( v, 4.0, 'returns expected value' ); t.end(); @@ -157,7 +152,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -173,9 +167,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { NaN, NaN // 4 ]; - N = floor( x.length / 2 ); - v = nanmax( N, x, 2, 1 ); + v = nanmax( 5, x, 2, 1 ); t.strictEqual( v, 4.0, 'returns expected value' ); t.end(); From c4b3073806e88556ffcbc6623171ab809fce6c68 Mon Sep 17 00:00:00 2001 From: aayush0325 Date: Sun, 9 Feb 2025 13:26:15 +0000 Subject: [PATCH 2/3] feat: add support for accessor arrays --- 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: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/nanmax/README.md | 3 + .../stats/base/nanmax/docs/types/index.d.ts | 11 +- .../stats/base/nanmax/docs/types/test.ts | 3 + .../stats/base/nanmax/lib/accessors.js | 96 ++++++++++++++ .../@stdlib/stats/base/nanmax/lib/ndarray.js | 7 + .../stats/base/nanmax/test/test.main.js | 98 ++++++++++++++ .../stats/base/nanmax/test/test.ndarray.js | 121 ++++++++++++++++++ 7 files changed, 336 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/nanmax/lib/accessors.js diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/README.md b/lib/node_modules/@stdlib/stats/base/nanmax/README.md index 0b9d78cb0c55..b36d027b7414 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/README.md +++ b/lib/node_modules/@stdlib/stats/base/nanmax/README.md @@ -109,6 +109,7 @@ var v = nanmax.ndarray( 5, x, 2, 1 ); ## Notes - If `N <= 0`, both functions return `NaN`. +- 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]). - Depending on the environment, the typed versions ([`dnanmax`][@stdlib/stats/base/dnanmax], [`snanmax`][@stdlib/stats/base/snanmax], etc.) are likely to be significantly more performant. @@ -170,6 +171,8 @@ console.log( v ); [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray +[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor + [@stdlib/stats/base/dnanmax]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dnanmax diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/index.d.ts index 07ffcee11c61..a756368647b9 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/index.d.ts @@ -20,7 +20,12 @@ /// -import { NumericArray } from '@stdlib/types/array'; +import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; + +/** +* Input array. +*/ +type InputArray = NumericArray | Collection | AccessorArrayLike; /** * Interface describing `nanmax`. @@ -40,7 +45,7 @@ interface Routine { * var v = nanmax( x.length, x, 1 ); * // returns 2.0 */ - ( N: number, x: NumericArray, strideX: number ): number; + ( N: number, x: InputArray, strideX: number ): number; /** * Computes the maximum value of a strided array, ignoring `NaN` values and using alternative indexing semantics. @@ -57,7 +62,7 @@ interface Routine { * var v = nanmax.ndarray( x.length, x, 1, 0 ); * // returns 2.0 */ - ndarray( N: number, x: NumericArray, strideX: number, offsetX: number ): number; + ndarray( N: number, x: InputArray, strideX: number, offsetX: number ): number; } /** diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/test.ts index 8cdf68ec1590..35e8830ace54 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/nanmax/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import AccessorArray = require( '@stdlib/array/base/accessor' ); import nanmax = require( './index' ); @@ -26,6 +27,7 @@ import nanmax = require( './index' ); const x = new Float64Array( 10 ); nanmax( x.length, x, 1 ); // $ExpectType number + nanmax( x.length, new AccessorArray( x ), 1 ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -85,6 +87,7 @@ import nanmax = require( './index' ); const x = new Float64Array( 10 ); nanmax.ndarray( x.length, x, 1, 0 ); // $ExpectType number + nanmax.ndarray( x.length, new AccessorArray( x ), 1, 0 ); // $ExpectType number } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/nanmax/lib/accessors.js new file mode 100644 index 000000000000..4f6f9e5ec911 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/nanmax/lib/accessors.js @@ -0,0 +1,96 @@ +/** +* @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 isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); + + +// MAIN // + +/** +* Computes the maximum value of a strided array, ignoring `NaN` values. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {Object} x - input array object +* @param {Collection} x.data - input array data +* @param {Array} x.accessors - array element accessors +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @returns {number} maximum value +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = toAccessorArray( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); +* +* var v = nanmax( 5, arraylike2object( x ), 2, 1 ); +* // returns 4.0 +*/ +function nanmax( N, x, strideX, offsetX ) { + var xbuf; + var get; + var max; + 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 === 1 || strideX === 0 ) { + return get( xbuf, offsetX ); + } + ix = offsetX; + for ( i = 0; i < N; i++ ) { + v = get( xbuf, ix ); + if ( v === v ) { + break; + } + ix += strideX; + } + if ( i === N ) { + return NaN; + } + max = v; + i += 1; + for ( i; i < N; i++ ) { + ix += strideX; + v = get( xbuf, ix ); + if ( isnan( v ) ) { + continue; + } + if ( v > max || ( v === max && isPositiveZero( v ) ) ) { + max = v; + } + } + return max; +} + + +// EXPORTS // + +module.exports = nanmax; diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmax/lib/ndarray.js index 1f2f8aa569b6..4f1c7462afbb 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/lib/ndarray.js @@ -22,6 +22,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var accessors = require( './accessors.js' ); // MAIN // @@ -44,12 +46,17 @@ var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); function nanmax( N, x, strideX, offsetX ) { var max; var ix; + var o; var v; var i; if ( N <= 0 ) { return NaN; } + o = arraylike2object( x ); + if ( o.accessorProtocol ) { + return accessors( N, o, strideX, offsetX ); + } if ( N === 1 || strideX === 0 ) { return x[ offsetX ]; } diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/test/test.main.js b/lib/node_modules/@stdlib/stats/base/nanmax/test/test.main.js index f4488c886b4e..9c33e47161ae 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/test/test.main.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/test/test.main.js @@ -23,6 +23,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var Float64Array = require( '@stdlib/array/float64' ); var nanmax = require( './../lib/main.js' ); @@ -67,6 +68,33 @@ tape( 'the function calculates the maximum value of a strided array', function t t.end(); }); +tape( 'the function calculates the maximum value of a strided array (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0, NaN, NaN ]; + v = nanmax( x.length, toAccessorArray( x ), 1 ); + t.strictEqual( v, 5.0, 'returns expected value' ); + + x = [ -4.0, NaN, -5.0 ]; + v = nanmax( x.length, toAccessorArray( x ), 1 ); + t.strictEqual( v, -4.0, 'returns expected value' ); + + x = [ -0.0, NaN, 0.0, -0.0 ]; + v = nanmax( x.length, toAccessorArray( x ), 1 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = nanmax( x.length, toAccessorArray( x ), 1 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = nanmax( x.length, toAccessorArray( x ), 1 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { var x; var v; @@ -94,6 +122,18 @@ 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 element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = nanmax( 1, toAccessorArray( x ), 1 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports a `stride` parameter', function test( t ) { var x; var v; @@ -117,6 +157,29 @@ tape( 'the function supports a `stride` parameter', function test( t ) { t.end(); }); +tape( 'the function supports a `stride` parameter (accessors)', function test( t ) { + 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 + ]; + + v = nanmax( 5, toAccessorArray( x ), 2 ); + + t.strictEqual( v, 4.0, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports a negative `stride` parameter', function test( t ) { var x; var v; @@ -140,6 +203,29 @@ 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 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 + ]; + + v = nanmax( 5, toAccessorArray( x ), -2 ); + + t.strictEqual( v, 4.0, 'returns expected value' ); + t.end(); +}); + tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element', function test( t ) { var x; var v; @@ -152,6 +238,18 @@ 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 element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = nanmax( x.length, toAccessorArray( x ), 0 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports view offsets', function test( t ) { var x0; var x1; diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmax/test/test.ndarray.js index 8b37e605ec07..de7bce6ccd3c 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/test/test.ndarray.js @@ -23,6 +23,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var nanmax = require( './../lib/ndarray.js' ); @@ -66,6 +67,33 @@ tape( 'the function calculates the maximum value of a strided array', function t t.end(); }); +tape( 'the function calculates the maximum value of a strided array (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, NaN, 0.0, 3.0 ]; + v = nanmax( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, 5.0, 'returns expected value' ); + + x = [ -4.0, NaN, -5.0 ]; + v = nanmax( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, -4.0, 'returns expected value' ); + + x = [ -0.0, 0.0, NaN, -0.0 ]; + v = nanmax( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + x = [ NaN ]; + v = nanmax( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + x = [ NaN, NaN ]; + v = nanmax( x.length, toAccessorArray( x ), 1, 0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { var x; var v; @@ -93,6 +121,18 @@ 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 indexed element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = nanmax( 1, toAccessorArray( x ), 1, 0 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports a `stride` parameter', function test( t ) { var x; var v; @@ -116,6 +156,29 @@ tape( 'the function supports a `stride` parameter', function test( t ) { t.end(); }); +tape( 'the function supports a `stride` parameter (accessors)', function test( t ) { + 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 + ]; + + v = nanmax( 5, toAccessorArray( x ), 2, 0 ); + + t.strictEqual( v, 4.0, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports a negative `stride` parameter', function test( t ) { var x; var v; @@ -139,6 +202,29 @@ 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 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 + ]; + + v = nanmax( 5, toAccessorArray( x ), -2, 8 ); + + t.strictEqual( v, 4.0, 'returns expected value' ); + t.end(); +}); + tape( 'if provided a `stride` parameter equal to `0`, the function returns the first indexed element', function test( t ) { var x; var v; @@ -151,6 +237,18 @@ 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 indexed element (accessors)', function test( t ) { + var x; + var v; + + x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ]; + + v = nanmax( x.length, toAccessorArray( x ), 0, 0 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports an `offset` parameter', function test( t ) { var x; var v; @@ -173,3 +271,26 @@ 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 = [ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0, // 3 + NaN, + NaN // 4 + ]; + + v = nanmax( 5, toAccessorArray( x ), 2, 1 ); + t.strictEqual( v, 4.0, 'returns expected value' ); + + t.end(); +}); From 3906905fdc228e6f5b3bb520aadf293b2080ccb7 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 9 Feb 2025 12:43:38 -0800 Subject: [PATCH 3/3] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/stats/base/nanmax/benchmark/benchmark.js | 4 ++-- .../@stdlib/stats/base/nanmax/benchmark/benchmark.ndarray.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.js index cd9980ebe20b..baa265220d86 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.js @@ -33,10 +33,10 @@ var nanmax = require( './../lib/main.js' ); // FUNCTIONS // /** -* Returns a random value or `NaN`. +* Returns a random number. * * @private -* @returns {number} random number or `NaN` +* @returns {number} random number */ function rand() { if ( bernoulli( 0.8 ) < 1 ) { diff --git a/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.ndarray.js index c007f2865581..15f9a39fa5c5 100644 --- a/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/nanmax/benchmark/benchmark.ndarray.js @@ -33,10 +33,10 @@ var nanmax = require( './../lib/ndarray.js' ); // FUNCTIONS // /** -* Returns a random value or `NaN`. +* Returns a random number. * * @private -* @returns {number} random number or `NaN` +* @returns {number} random number */ function rand() { if ( bernoulli( 0.8 ) < 1 ) {