From f3d4e018cf051f04eae9758b3fd7d617acf35ee9 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sat, 8 Mar 2025 15:02:41 +0530 Subject: [PATCH 01/11] edit --- .../@stdlib/stats/base/dists/uniform/mgf/src/main.c | 2 +- .../@stdlib/stats/base/dists/uniform/mgf/test/test.native.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/src/main.c index 49105477756c..4feab3bb73be 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/src/main.c @@ -46,5 +46,5 @@ double stdlib_base_dists_uniform_mgf( const double t, const double a, const doub return 1.0; } // Case: t not equal to zero - return ( stdlib_base_exp( t * b ) - stdlib_base_exp( t * a ) ) / ( t * ( b - a ) ); + return stdlib_base_exp( v ) * ( stdlib_base_sinh ( u ) / u ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/test/test.native.js index bc312890bdf3..868d3aae948d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/test/test.native.js @@ -81,7 +81,7 @@ tape( 'if provided `a >= b`, the function returns `NaN`', opts, function test( t t.end(); }); -tape( 'if provided valid parameters, the function returns `1` for `t = 0`', function test( t ) { +tape( 'if provided valid parameters, the function returns `1` for `t = 0`', opts, function test( t ) { var y; y = mgf( 0.0, 2.0, 4.0 ); From ddced1cd3eb3a9a64ec05119e719344ecff0bbaf Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sat, 8 Mar 2025 15:10:15 +0530 Subject: [PATCH 02/11] edit --- .../@stdlib/stats/base/dists/uniform/mgf/src/main.c | 2 +- .../@stdlib/stats/base/dists/uniform/mgf/test/test.native.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/src/main.c index 4feab3bb73be..49105477756c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/src/main.c @@ -46,5 +46,5 @@ double stdlib_base_dists_uniform_mgf( const double t, const double a, const doub return 1.0; } // Case: t not equal to zero - return stdlib_base_exp( v ) * ( stdlib_base_sinh ( u ) / u ); + return ( stdlib_base_exp( t * b ) - stdlib_base_exp( t * a ) ) / ( t * ( b - a ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/test/test.native.js index 868d3aae948d..bc312890bdf3 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/uniform/mgf/test/test.native.js @@ -81,7 +81,7 @@ tape( 'if provided `a >= b`, the function returns `NaN`', opts, function test( t t.end(); }); -tape( 'if provided valid parameters, the function returns `1` for `t = 0`', opts, function test( t ) { +tape( 'if provided valid parameters, the function returns `1` for `t = 0`', function test( t ) { var y; y = mgf( 0.0, 2.0, 4.0 ); From ea5425b90975ff345153327c40a9eac0ffea62d9 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 11:01:32 +0530 Subject: [PATCH 03/11] added nanmax --- .../@stdlib/stats/incr/nanmax/README.md | 150 ++++++++++++++++++ .../stats/incr/nanmax/benchmark/benchmark.js | 69 ++++++++ .../@stdlib/stats/incr/nanmax/docs/repl.txt | 36 +++++ .../stats/incr/nanmax/docs/types/index.d.ts | 66 ++++++++ .../stats/incr/nanmax/docs/types/test.ts | 61 +++++++ .../stats/incr/nanmax/examples/index.js | 43 +++++ .../@stdlib/stats/incr/nanmax/lib/index.js | 57 +++++++ .../@stdlib/stats/incr/nanmax/lib/main.js | 81 ++++++++++ .../@stdlib/stats/incr/nanmax/package.json | 68 ++++++++ .../@stdlib/stats/incr/nanmax/test/test.js | 118 ++++++++++++++ 10 files changed, 749 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmax/README.md create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmax/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmax/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmax/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmax/package.json create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/README.md b/lib/node_modules/@stdlib/stats/incr/nanmax/README.md new file mode 100644 index 000000000000..fe2c70bbc966 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/README.md @@ -0,0 +1,150 @@ + + +# incrnanmax + +> Compute a maximum value incrementally, while ignoring `NaN` values. + +
+ +## Usage + +```javascript +var incrnanmax = require( '@stdlib/stats/incr/nanmax' ); +``` + +#### incrnanmax() + +Returns an accumulator `function` which incrementally computes a maximum value, while ignoring `NaN` values. + +```javascript +var accumulator = incrnanmax(); +``` + +#### accumulator( \[x] ) + +If provided an input value `x`, the accumulator function returns an updated maximum value. If not provided an input value `x`, the accumulator function returns the current maximum value. + +```javascript +var accumulator = incrnanmax(); + +var max = accumulator( 2.0 ); +// returns 2.0 + +max = accumulator( 1.0 ); +// returns 2.0 + +max = accumulator( NaN ); +// returns 2.0 + +max = accumulator( 3.0 ); +// returns 3.0 + +max = accumulator(); +// returns 3.0 +``` + +
+ + + +
+ +## Notes + +- Input values are **not** type checked. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function. +- For long running accumulations or accumulations of large numbers, care should be taken to prevent overflow. + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var incrnanmax = require( '@stdlib/stats/incr/nanmax' ); + +var accumulator; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanmax(); + +// For each simulated datum, update the max... +for ( i = 0; i < 100; i++ ) { + if ( randu() < 0.2 ) { + v = NaN; + } else { + v = randu() * 100.0; + } + accumulator( v ); +} +console.log( accumulator() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmax/benchmark/benchmark.js new file mode 100644 index 000000000000..8b5b6cbb2083 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/benchmark/benchmark.js @@ -0,0 +1,69 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var pkg = require( './../package.json' ).name; +var incrnanmax = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var f; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = incrnanmax(); + if ( typeof f !== 'function' ) { + b.fail( 'should return a function' ); + } + } + b.toc(); + if ( typeof f !== 'function' ) { + b.fail( 'should return a function' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::accumulator', function benchmark( b ) { + var acc; + var v; + var i; + + acc = incrnanmax(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = acc( randu() ); + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/repl.txt new file mode 100644 index 000000000000..07176edde16f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/repl.txt @@ -0,0 +1,36 @@ + +{{alias}}() + Returns an accumulator function which incrementally computes a maximum + value, ignoring `NaN` values. + + If provided a value, the accumulator function returns an updated maximum + value. If not provided a value, the accumulator function returns the current + maximum value. + + For long running accumulations or accumulations of large numbers, care + should be taken to prevent overflow. + + Returns + ------- + acc: Function + Accumulator function. + + Examples + -------- + > var accumulator = {{alias}}(); + > var m = accumulator() + null + > m = accumulator( 3.14 ) + 3.14 + > m = accumulator( NaN ) + 3.14 + > m = accumulator( -5.0 ) + 3.14 + > m = accumulator( 10.1 ) + 10.1 + > m = accumulator() + 10.1 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts new file mode 100644 index 000000000000..9594a2a4c122 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts @@ -0,0 +1,66 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/// + +/** +* If provided a value, returns an updated maximum value; otherwise, returns the current maximum value. +* +* ## Notes +* +* - If provided `NaN` or a value which, when used in computations, results in `NaN`, the accumulated value is `NaN` for all future invocations. +* +* @param x - value +* @returns maximum value +*/ +type accumulator = ( x?: number ) => number | null; + +/** +* Returns an accumulator function which incrementally computes a maximum value, while ignoring `NaN` values. +* +* @returns accumulator function +* +* @example +* var accumulator = incrnanmax(); +* +* var v = accumulator(); +* // returns null +* +* v = accumulator( 2.0 ); +* // returns 2.0 +* +* v = accumulator( -4.0 ); +* // returns 2.0 +* +* * v = accumulator( NaN ); +* // returns 2.0 +* +* v = accumulator( 3.0 ); +* // returns 3.0 +* +* v = accumulator(); +* // returns 3.0 +*/ +declare function incrnanmax(): accumulator; + + +// EXPORTS // + +export = incrnanmax; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts new file mode 100644 index 000000000000..e039d0187540 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts @@ -0,0 +1,61 @@ +/* +* @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. +*/ + +import incrnanmax = require( './index' ); + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnanmax(); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided arguments... +{ + incrnanmax( '5' ); // $ExpectError + incrnanmax( 5 ); // $ExpectError + incrnanmax( true ); // $ExpectError + incrnanmax( false ); // $ExpectError + incrnanmax( null ); // $ExpectError + incrnanmax( undefined ); // $ExpectError + incrnanmax( [] ); // $ExpectError + incrnanmax( {} ); // $ExpectError + incrnanmax( ( x: number ): number => x ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnanmax(); + + acc(); // $ExpectType number | null + acc( 3.14 ); // $ExpectType number | null +} + +// The compiler throws an error if the returned accumulator function is provided invalid arguments... +{ + const acc = incrnanmax(); + + acc( '5' ); // $ExpectError + acc( true ); // $ExpectError + acc( false ); // $ExpectError + acc( null ); // $ExpectError + acc( [] ); // $ExpectError + acc( {} ); // $ExpectError + acc( ( x: number ): number => x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js new file mode 100644 index 000000000000..9fee4e0b4d3b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js @@ -0,0 +1,43 @@ +/** +* @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'; + +var randu = require( '@stdlib/random/base/randu' ); +var incrnanmax = require( './../lib' ); + +var accumulator; +var max; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanmax(); + +// For each simulated datum, update the max... +console.log( '\nValue\tMax\n' ); +for ( i = 0; i < 100; i++ ) { + if ( randu() < 0.2 ) { + v = NaN; + } else { + v = randu() * 100.0; + } + max = accumulator( v ); + console.log( '%d\t%d', v.toFixed( 4 ),( max === null ) ? NaN : max.toFixed( 4 ) ); +} +console.log( '\nFinal max: %d\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/index.js new file mode 100644 index 000000000000..496747f0cb46 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/index.js @@ -0,0 +1,57 @@ +/** +* @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'; + +/** +* Compute a maximum value incrementally, ignoring `NaN` values. +* +* @module @stdlib/stats/incr/nanmax +* +* @example +* var incrnanmax = require( '@stdlib/stats/incr/nanmax' ); +* +* var accumulator = incrnanmax(); +* +* var max = accumulator(); +* // returns null +* +* max = accumulator( 3.14 ); +* // returns 3.14 +* +* max = accumulator( NaN ); +* // returns 3.14 +* +* max = accumulator( -5.0 ); +* // returns 3.14 +* +* max = accumulator( 10.1 ); +* // returns 10.1 +* +* max = accumulator(); +* // returns 10.1 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js new file mode 100644 index 000000000000..57fc53c3398d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js @@ -0,0 +1,81 @@ +/** +* @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' ); +var incrmax = require( '@stdlib/stats/incr/max' ); + + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes a maximum value. +* +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrmax(); +* +* var max = accumulator(); +* // returns null +* +* max = accumulator( 3.14 ); +* // returns 3.14 +* +* max = accumulator( NaN ); +* // returns 3.14 +* +* max = accumulator( -5.0 ); +* // returns 3.14 +* +* max = accumulator( 10.1 ); +* // returns 10.1 +* +* max = accumulator(); +* // returns 10.1 +*/ +function incrnanmax() { + var max = incrmax(); + return accumulator; + + /** + * If provided a value, the accumulator function returns an updated maximum value. If not provided a value, the accumulator function returns the current max, while ignoring `NaN` values. + * + * @private + * @param {number} [x] - new value + * @returns {(number|null)} max value or null + */ + function accumulator( x ) { + if ( arguments.length === 0 ) { + return max(); + } + if ( isnan( x ) ) { + return max(); + } + return max( x ); + } +} + + +// EXPORTS // + +module.exports = incrnanmax; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/package.json b/lib/node_modules/@stdlib/stats/incr/nanmax/package.json new file mode 100644 index 000000000000..545f73c7d532 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/stats/incr/nanmax", + "version": "0.0.0", + "description": "Compute a maximum value incrementally.", + "license": "Apache-2.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" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "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": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "mathematics", + "math", + "maximum", + "max", + "range", + "extremes", + "domain", + "extent", + "incremental", + "accumulator" + ] + } + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js new file mode 100644 index 000000000000..61721a164efb --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js @@ -0,0 +1,118 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var incrnanmax = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrnanmax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.equal( typeof incrnanmax(), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'if not provided any values, the initial returned maximum value is `null`', function test( t ) { + var acc = incrnanmax(); + t.equal( acc(), null, 'returns null' ); + t.end(); +}); + +tape( 'the accumulator function incrementally computes a maximum value, ignoring NaN values', function test( t ) { + var expected; + var actual; + var data; + var acc; + var max; + var N; + var d; + var i; + + data = [ 2.0, NaN, 3.0, NaN, 4.0, 3.0, NaN, 4.0 ]; + N = data.length; + + expected = [ 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0 ]; + actual = new Array( N ); + + acc = incrnanmax(); + + for ( i = 0; i < N; i++ ) { + d = data[ i ]; + actual[ i ] = acc( d ); + } + t.deepEqual( actual, expected, 'returns expected incremental results' ); + t.end(); +}); + +tape( 'if not provided an input value, the accumulator function returns the current maximum value', function test( t ) { + var data; + var acc; + var i; + + data = [ 2.0, 3.0, NaN, 1.0 ]; + acc = incrnanmax(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); + } + t.equal( acc(), 3.0, 'returns the current accumulated maximum value' ); + t.end(); +}); + +tape( 'the accumulator function correctly handles signed zeros', function test( t ) { + var acc; + var v; + + acc = incrnanmax(); + + v = acc( -0.0 ); + t.equal( isNegativeZero( v ), true, 'returns expected value' ); + + v = acc( 0.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + + v = acc( -0.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `NaN`, the accumulator function ignores it and continues computing max value', function test( t ) { + var data; + var acc; + var i; + + data = [ 2.0, NaN, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ]; + acc = incrnanmax(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); + } + t.equal( acc(), 7.0, 'returns expected value' ); + t.end(); +}); From 31a58a37e6faa5889827042a0e5da32d7d20e696 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 11:23:26 +0530 Subject: [PATCH 04/11] lint error --- .../stats/incr/nanmax/docs/types/index.d.ts | 2 +- .../@stdlib/stats/incr/nanmax/lib/main.js | 5 +- .../@stdlib/stats/incr/nanmax/package.json | 129 +++++++++--------- .../@stdlib/stats/incr/nanmax/test/test.js | 6 +- 4 files changed, 70 insertions(+), 72 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts index 9594a2a4c122..a569138db5ed 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts @@ -49,7 +49,7 @@ type accumulator = ( x?: number ) => number | null; * v = accumulator( -4.0 ); * // returns 2.0 * -* * v = accumulator( NaN ); +* v = accumulator( NaN ); * // returns 2.0 * * v = accumulator( 3.0 ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js index 57fc53c3398d..a1fe95a5c359 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js @@ -21,14 +21,13 @@ // MODULES // var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); -var incrmax = require( '@stdlib/stats/incr/max' ); +var incrmax = require( '@stdlib/stats/incr/max' ); // MAIN // /** -* Returns an accumulator function which incrementally computes a maximum value. +* Returns an accumulator function which incrementally computes a maximum value, ignoring `NaN` values. * * @returns {Function} accumulator function * diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/package.json b/lib/node_modules/@stdlib/stats/incr/nanmax/package.json index 545f73c7d532..dc6c0fb14f8c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/package.json @@ -1,68 +1,67 @@ { - "name": "@stdlib/stats/incr/nanmax", - "version": "0.0.0", - "description": "Compute a maximum value incrementally.", - "license": "Apache-2.0", - "author": { + "name": "@stdlib/stats/incr/nanmax", + "version": "0.0.0", + "description": "Compute a maximum value incrementally, while ignoring `NaN` values.", + "license": "Apache-2.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" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "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": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdmath", - "statistics", - "stats", - "mathematics", - "math", - "maximum", - "max", - "range", - "extremes", - "domain", - "extent", - "incremental", - "accumulator" - ] - } - \ No newline at end of file + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "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": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "mathematics", + "math", + "maximum", + "max", + "range", + "variance", + "domain", + "extent", + "incremental", + "accumulator" + ] +} \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js index 61721a164efb..2abedf1afab0 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 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. @@ -35,8 +35,8 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function returns an accumulator function', function test( t ) { - t.equal( typeof incrnanmax(), 'function', 'returns a function' ); - t.end(); + t.equal( typeof incrnanmax(), 'function', 'returns a function' ); + t.end(); }); tape( 'if not provided any values, the initial returned maximum value is `null`', function test( t ) { From eaca68c2be3753d4053f65007c42108bfaf1080c Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 11:36:03 +0530 Subject: [PATCH 05/11] verify --- .../stats/incr/nanmax/docs/types/test.ts | 20 +++++++++---------- .../@stdlib/stats/incr/nanmax/package.json | 2 +- .../@stdlib/stats/incr/nanmax/test/test.js | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts index e039d0187540..bcc5d8617c89 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts @@ -23,20 +23,20 @@ import incrnanmax = require( './index' ); // The function returns an accumulator function... { - incrnanmax(); // $ExpectType accumulator + incrnanmax(); // $ExpectType accumulator } // The compiler throws an error if the function is provided arguments... { - incrnanmax( '5' ); // $ExpectError - incrnanmax( 5 ); // $ExpectError - incrnanmax( true ); // $ExpectError - incrnanmax( false ); // $ExpectError - incrnanmax( null ); // $ExpectError - incrnanmax( undefined ); // $ExpectError - incrnanmax( [] ); // $ExpectError - incrnanmax( {} ); // $ExpectError - incrnanmax( ( x: number ): number => x ); // $ExpectError + incrnanmax( '5' ); // $ExpectError + incrnanmax( 5 ); // $ExpectError + incrnanmax( true ); // $ExpectError + incrnanmax( false ); // $ExpectError + incrnanmax( null ); // $ExpectError + incrnanmax( undefined ); // $ExpectError + incrnanmax( [] ); // $ExpectError + incrnanmax( {} ); // $ExpectError + incrnanmax( ( x: number ): number => x ); // $ExpectError } // The function returns an accumulator function which returns an accumulated result... diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/package.json b/lib/node_modules/@stdlib/stats/incr/nanmax/package.json index dc6c0fb14f8c..ecdd4a17d7aa 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/package.json @@ -64,4 +64,4 @@ "incremental", "accumulator" ] -} \ No newline at end of file +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js index 2abedf1afab0..1cd466a255c9 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js @@ -34,9 +34,9 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function returns an accumulator function', function test( t ) { - t.equal( typeof incrnanmax(), 'function', 'returns a function' ); - t.end(); +tape( 'the function returns an accumulator function', function test( t ) { + t.equal( typeof incrnanmax(), 'function', 'returns a function' ); + t.end(); }); tape( 'if not provided any values, the initial returned maximum value is `null`', function test( t ) { From fe12468fbd0a3ac9ab4c09152d84b96971b008a5 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 11:43:06 +0530 Subject: [PATCH 06/11] check --- lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js index a1fe95a5c359..b944d174654a 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js @@ -32,7 +32,7 @@ var incrmax = require( '@stdlib/stats/incr/max' ); * @returns {Function} accumulator function * * @example -* var accumulator = incrmax(); +* var accumulator = incrnanmax(); * * var max = accumulator(); * // returns null From 3ff2128f425ab8b80b00ba79644c180d9326c45a Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 14:28:11 +0530 Subject: [PATCH 07/11] ident --- .../stats/incr/nanmax/docs/types/test.ts | 24 +++++++++---------- .../stats/incr/nanmax/examples/index.js | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts index bcc5d8617c89..2971390a00fc 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts @@ -41,21 +41,21 @@ import incrnanmax = require( './index' ); // The function returns an accumulator function which returns an accumulated result... { - const acc = incrnanmax(); + const acc = incrnanmax(); - acc(); // $ExpectType number | null - acc( 3.14 ); // $ExpectType number | null + acc(); // $ExpectType number | null + acc( 3.14 ); // $ExpectType number | null } // The compiler throws an error if the returned accumulator function is provided invalid arguments... { - const acc = incrnanmax(); - - acc( '5' ); // $ExpectError - acc( true ); // $ExpectError - acc( false ); // $ExpectError - acc( null ); // $ExpectError - acc( [] ); // $ExpectError - acc( {} ); // $ExpectError - acc( ( x: number ): number => x ); // $ExpectError + const acc = incrnanmax(); + + acc( '5' ); // $ExpectError + acc( true ); // $ExpectError + acc( false ); // $ExpectError + acc( null ); // $ExpectError + acc( [] ); // $ExpectError + acc( {} ); // $ExpectError + acc( ( x: number ): number => x ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js index 9fee4e0b4d3b..abee9c8bc0b5 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js @@ -38,6 +38,6 @@ for ( i = 0; i < 100; i++ ) { v = randu() * 100.0; } max = accumulator( v ); - console.log( '%d\t%d', v.toFixed( 4 ),( max === null ) ? NaN : max.toFixed( 4 ) ); + console.log( '%d\t%d', v.toFixed( 4 ), ( max === null ) ? NaN : max.toFixed( 4 ) ); } console.log( '\nFinal max: %d\n', accumulator() ); From 5303568d9e7f8998f6b5a948c2f0f2c35c7c2925 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 14:33:06 +0530 Subject: [PATCH 08/11] reviewed --- lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js index 1cd466a255c9..cd729e2aa7cf 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js @@ -50,7 +50,6 @@ tape( 'the accumulator function incrementally computes a maximum value, ignoring var actual; var data; var acc; - var max; var N; var d; var i; From 1ad1cd2464a9fa006b0f7022544687b8c5d19347 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 20:21:06 +0530 Subject: [PATCH 09/11] constructor removed --- lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js index cd729e2aa7cf..7b5c004cb27c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js @@ -58,13 +58,13 @@ tape( 'the accumulator function incrementally computes a maximum value, ignoring N = data.length; expected = [ 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0 ]; - actual = new Array( N ); + actual = []; acc = incrnanmax(); for ( i = 0; i < N; i++ ) { d = data[ i ]; - actual[ i ] = acc( d ); + actual.push( acc ( d ) ); } t.deepEqual( actual, expected, 'returns expected incremental results' ); t.end(); From f2c591b172a6a992331b1c166b4fb4e14a16b505 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Wed, 12 Mar 2025 20:24:47 +0530 Subject: [PATCH 10/11] lint --- lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js index 7b5c004cb27c..31d2b230c507 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js @@ -64,7 +64,7 @@ tape( 'the accumulator function incrementally computes a maximum value, ignoring for ( i = 0; i < N; i++ ) { d = data[ i ]; - actual.push( acc ( d ) ); + actual.push( acc( d ) ); } t.deepEqual( actual, expected, 'returns expected incremental results' ); t.end(); From 7a8ed077ab2581700ce8e606be21b722c655eae9 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 6 Jul 2026 23:48:29 -0500 Subject: [PATCH 11/11] fix: address review feedback in stats/incr/nanmax - Remove incorrect NaN-propagation note from index.d.ts (contradicted the NaN-ignoring behavior) - Drop backticks from package.json description and align README/repl wording - Remove inappropriate overflow note (a maximum does not accumulate/sum) - Fix examples output to use %s and guard against a null accumulated value - Remove a stray tab in a test title; add an all-NaN returns-null test - Bump copyright year to 2026 --- .../@stdlib/stats/incr/nanmax/README.md | 27 +++---------------- .../stats/incr/nanmax/benchmark/benchmark.js | 2 +- .../@stdlib/stats/incr/nanmax/docs/repl.txt | 3 --- .../stats/incr/nanmax/docs/types/index.d.ts | 8 ++---- .../stats/incr/nanmax/docs/types/test.ts | 2 +- .../stats/incr/nanmax/examples/index.js | 4 +-- .../@stdlib/stats/incr/nanmax/lib/index.js | 2 +- .../@stdlib/stats/incr/nanmax/lib/main.js | 2 +- .../@stdlib/stats/incr/nanmax/package.json | 8 +++--- .../@stdlib/stats/incr/nanmax/test/test.js | 18 +++++++++++-- 10 files changed, 32 insertions(+), 44 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/README.md b/lib/node_modules/@stdlib/stats/incr/nanmax/README.md index fe2c70bbc966..b6fd07ac5841 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2025 The Stdlib Authors. +Copyright (c) 2026 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,7 @@ limitations under the License. # incrnanmax -> Compute a maximum value incrementally, while ignoring `NaN` values. +> Compute a maximum value incrementally, ignoring `NaN` values.
@@ -32,7 +32,7 @@ var incrnanmax = require( '@stdlib/stats/incr/nanmax' ); #### incrnanmax() -Returns an accumulator `function` which incrementally computes a maximum value, while ignoring `NaN` values. +Returns an accumulator `function` which incrementally computes a maximum value, ignoring `NaN` values. ```javascript var accumulator = incrnanmax(); @@ -70,7 +70,6 @@ max = accumulator(); ## Notes - Input values are **not** type checked. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function. -- For long running accumulations or accumulations of large numbers, care should be taken to prevent overflow.
@@ -113,16 +112,6 @@ console.log( accumulator() ); @@ -133,16 +122,6 @@ console.log( accumulator() ); -[@stdlib/stats/incr/midrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/midrange - -[@stdlib/stats/incr/min]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/min - -[@stdlib/stats/incr/mmax]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/mmax - -[@stdlib/stats/incr/range]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/range - -[@stdlib/stats/incr/summary]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/summary - diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmax/benchmark/benchmark.js index 8b5b6cbb2083..cd8425d3e315 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/repl.txt index 07176edde16f..def772da7585 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/repl.txt @@ -7,9 +7,6 @@ value. If not provided a value, the accumulator function returns the current maximum value. - For long running accumulations or accumulations of large numbers, care - should be taken to prevent overflow. - Returns ------- acc: Function diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts index a569138db5ed..7b9432f937ff 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 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. @@ -23,17 +23,13 @@ /** * If provided a value, returns an updated maximum value; otherwise, returns the current maximum value. * -* ## Notes -* -* - If provided `NaN` or a value which, when used in computations, results in `NaN`, the accumulated value is `NaN` for all future invocations. -* * @param x - value * @returns maximum value */ type accumulator = ( x?: number ) => number | null; /** -* Returns an accumulator function which incrementally computes a maximum value, while ignoring `NaN` values. +* Returns an accumulator function which incrementally computes a maximum value, ignoring `NaN` values. * * @returns accumulator function * diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts index 2971390a00fc..4ccf952c5ae6 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js index abee9c8bc0b5..adb2f9ec68f5 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,6 @@ for ( i = 0; i < 100; i++ ) { v = randu() * 100.0; } max = accumulator( v ); - console.log( '%d\t%d', v.toFixed( 4 ), ( max === null ) ? NaN : max.toFixed( 4 ) ); + console.log( '%s\t%s', ( v === v ) ? v.toFixed( 4 ) : 'NaN', ( max === null ) ? 'null' : max.toFixed( 4 ) ); } console.log( '\nFinal max: %d\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/index.js index 496747f0cb46..1e0021df8f0d 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js index b944d174654a..b1c462a79af1 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/package.json b/lib/node_modules/@stdlib/stats/incr/nanmax/package.json index ecdd4a17d7aa..89e854bb779c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/stats/incr/nanmax", "version": "0.0.0", - "description": "Compute a maximum value incrementally, while ignoring `NaN` values.", + "description": "Compute a maximum value incrementally, ignoring NaN values.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -58,10 +58,12 @@ "maximum", "max", "range", - "variance", + "extremes", "domain", "extent", "incremental", - "accumulator" + "accumulator", + "nan", + "ignore" ] } diff --git a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js index 31d2b230c507..c74c242f4a0e 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmax/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 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. @@ -34,7 +34,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function returns an accumulator function', function test( t ) { +tape( 'the function returns an accumulator function', function test( t ) { t.equal( typeof incrnanmax(), 'function', 'returns a function' ); t.end(); }); @@ -45,6 +45,20 @@ tape( 'if not provided any values, the initial returned maximum value is `null`' t.end(); }); +tape( 'if all provided values are `NaN`, the accumulator function returns `null`', function test( t ) { + var data; + var acc; + var i; + + data = [ NaN, NaN, NaN ]; + acc = incrnanmax(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); + } + t.equal( acc(), null, 'returns null' ); + t.end(); +}); + tape( 'the accumulator function incrementally computes a maximum value, ignoring NaN values', function test( t ) { var expected; var actual;