From c6a3eec4b9779d1d0a8a5bbff0114153109e0f9a Mon Sep 17 00:00:00 2001 From: "nirved.mishra.eee23@itbhu.ac.in" Date: Tue, 4 Mar 2025 19:41:59 +0530 Subject: [PATCH 1/9] feat(lib): added nansumprod package This commits add a package nansumprod, which works like sumprod in which it calculates sum of product of two number iteratively ignoring NaN values --- 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: passed - 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: passed - task: lint_license_headers status: passed --- --- .../@stdlib/stats/incr/nansumprod/README.md | 178 ++++++++++++++++++ .../incr/nansumprod/benchmark/benchmark.js | 69 +++++++ .../docs/img/equation_sum_product.svg | 40 ++++ .../stats/incr/nansumprod/docs/repl.txt | 34 ++++ .../incr/nansumprod/docs/types/index.d.ts | 60 ++++++ .../stats/incr/nansumprod/docs/types/test.ts | 69 +++++++ .../stats/incr/nansumprod/examples/index.js | 49 +++++ .../stats/incr/nansumprod/lib/index.js | 57 ++++++ .../@stdlib/stats/incr/nansumprod/lib/main.js | 78 ++++++++ .../stats/incr/nansumprod/package.json | 69 +++++++ .../stats/incr/nansumprod/test/test.js | 111 +++++++++++ 11 files changed, 814 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/incr/nansumprod/README.md create mode 100644 lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nansumprod/docs/img/equation_sum_product.svg create mode 100644 lib/node_modules/@stdlib/stats/incr/nansumprod/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nansumprod/package.json create mode 100644 lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.js diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md b/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md new file mode 100644 index 000000000000..bbc580bd0584 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md @@ -0,0 +1,178 @@ + + +# incrnansumprod + +> Compute a sum of products incrementally ignoring `NaN` values. + +
+ +The sum of products is defined as + + + +```math +s = \sum_{i=0}^{n-1} x_i y_i +``` + + + + + +
+ + + +
+ +## Usage + +```javascript +var incrnansumprod = require( '@stdlib/stats/incr/nansumprod' ); +``` + +#### incrnansumprod() + +Returns an accumulator `function` which incrementally computes a sum of products, ignoring `NaN` values. + +```javascript +var accumulator = incrnansumprod(); +``` + +#### accumulator( \[x, y] ) + +If provided input values `x` and `y`, the accumulator function returns an updated sum. If not provided input value `x` and `y`, the accumulator function returns the current sum. + +```javascript +var accumulator = incrnansumprod(); + +var sum = accumulator( 2.0, 3.0 ); +// returns 6.0 + +sum = accumulator( 1.0, -1.0 ); +// returns 5.0 + +sum = accumulator( NaN, NaN ); +// returns 5.0 + +sum = accumulator( 3, NaN ); +// returns 5.0 + +sum = accumulator( 3.0, 4.0 ); +// returns 17.0 + +sum = accumulator(); +// returns 17.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 incrnansumprod = require( '@stdlib/stats/incr/nansumprod' ); + +var accumulator; +var v1; +var v2; +var i; + +// Initialize an accumulator: +accumulator = incrnansumprod(); + +// For each simulated datum, update the sum-product... +for ( i = 0; i < 100; i++ ) { + if ( randu() < 0.2 ) { + v1 = NaN; + v2 = NaN; + } else if ( randu() < 0.3 ) { + v1 = NaN; + v2 = randu() * 100.0; + } else { + v1 = randu() * 100.0; + v2 = randu() * 100.0; + } + accumulator( v1, v2 ); +} +console.log( accumulator() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js new file mode 100644 index 000000000000..f240f8df5762 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js @@ -0,0 +1,69 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var pkg = require( './../package.json' ).name; +var incrnansumprod = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var f; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = incrnansumprod(); + 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 = incrnansumprod(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = acc( randu()*10.0, randu()*10.0 ); + 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/nansumprod/docs/img/equation_sum_product.svg b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/img/equation_sum_product.svg new file mode 100644 index 000000000000..3e2856635040 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/img/equation_sum_product.svg @@ -0,0 +1,40 @@ + +s equals sigma-summation Underscript i equals 0 Overscript n minus 1 Endscripts x Subscript i Baseline y Subscript i + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/repl.txt new file mode 100644 index 000000000000..0aedf70e24cc --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/repl.txt @@ -0,0 +1,34 @@ + +{{alias}}() + Returns an accumulator function which incrementally computes a sum of + products, ignoring `NaN` values. + + If provided input values, the accumulator function returns an updated sum. + If not provided input values, the accumulator function returns the current + sum. + + 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 s = accumulator() + null + > s = accumulator( 2.0, 3.0 ) + 6.0 + > s = accumulator( -5.0, 2.0 ) + -4.0 + > s = accumulator( NaN, 6.0 ) + -4.0 + > s = accumulator() + -4.0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts new file mode 100644 index 000000000000..4a227901b379 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts @@ -0,0 +1,60 @@ +/** +* @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. +*/ + +// TypeScript Version: 4.1 + +/// + +/** +* If provided arguments, returns an updated sum of products; otherwise, returns the current sum of products. +* +* @param x - value +* @param y - value +* @returns sum of products +*/ +type accumulator = ( x?: number, y?: number ) => number | null; + +/** +* Returns an accumulator function which incrementally computes a sum of products, ignoring `NaN` values. +* +* @returns accumulator function +* +* @example +* var accumulator = incrsumprod(); +* +* var v = accumulator(); +* // returns null +* +* v = accumulator( 2.0, 3.0 ); +* // returns 6.0 +* +* v = accumulator( -5.0, 2.0 ); +* // returns -4.0 +* +* v = accumulator( NaN, 6.0 ); +* // returns -4.0 +* +* v = accumulator(); +* // returns -4.0 +*/ +declare function incrnansumprod(): accumulator; + + +// EXPORTS // + +export = incrnansumprod; diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/test.ts new file mode 100644 index 000000000000..1eff87cf2bd4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/test.ts @@ -0,0 +1,69 @@ +/** +* @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. +*/ + +import incrnansumprod = require( './index' ); + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnansumprod(); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided arguments... +{ + incrnansumprod( '5' ); // $ExpectError + incrnansumprod( 5 ); // $ExpectError + incrnansumprod( true ); // $ExpectError + incrnansumprod( false ); // $ExpectError + incrnansumprod( null ); // $ExpectError + incrnansumprod( undefined ); // $ExpectError + incrnansumprod( [] ); // $ExpectError + incrnansumprod( {} ); // $ExpectError + incrnansumprod( ( x: number ): number => x ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnansumprod(); + + acc(); // $ExpectType number | null + acc( 3.14, 2.0 ); // $ExpectType number | null +} + +// The compiler throws an error if the returned accumulator function is provided invalid arguments... +{ + const acc = incrnansumprod(); + + acc( '5', 1.0 ); // $ExpectError + acc( true, 1.0 ); // $ExpectError + acc( false, 1.0 ); // $ExpectError + acc( null, 1.0 ); // $ExpectError + acc( [], 1.0 ); // $ExpectError + acc( {}, 1.0 ); // $ExpectError + acc( ( x: number ): number => x, 1.0 ); // $ExpectError + + acc( 3.14, '5' ); // $ExpectError + acc( 3.14, true ); // $ExpectError + acc( 3.14, false ); // $ExpectError + acc( 3.14, null ); // $ExpectError + acc( 3.14, [] ); // $ExpectError + acc( 3.14, {} ); // $ExpectError + acc( 3.14, ( x: number ): number => x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js new file mode 100644 index 000000000000..c799db24e1a5 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js @@ -0,0 +1,49 @@ +/** +* @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'; + +var randu = require( '@stdlib/random/base/randu' ); +var incrnansumprod = require( './../lib' ); + +var accumulator; +var sum; +var v1; +var v2; +var i; + +// Initialize an accumulator: +accumulator = incrnansumprod(); + +// For each simulated datum, update the sum-product... +console.log( '\nValue\tValue\tSum-Product\n' ); +for ( i = 0; i < 100; i++ ) { + if ( randu() < 0.2 ) { + v1 = NaN; + v2 = NaN; + } else if ( randu() < 0.3 ) { + v1 = NaN; + v2 = randu() * 100.0; + } else { + v1 = randu() * 100.0; + v2 = randu() * 100.0; + } + sum = accumulator( v1, v2 ); + console.log( '%d\t%d\t%d', v1.toFixed( 4 ), v2.toFixed( 4 ), sum.toFixed( 4 ) ); +} +console.log( '\nFinal sum-product: %d\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js new file mode 100644 index 000000000000..020d07c2c325 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js @@ -0,0 +1,57 @@ +/** +* @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'; + +/** +* Compute a sum of products incrementally ignoring `NaN` values. +* +* @module @stdlib/stats/incr/nansumprod +* +* @example +* var incrnansumprod = require( '@stdlib/stats/incr/nansumprod' ); +* +* var accumulator = incrnansumprod(); +* +* var sum = accumulator( 2.0, 3.0 ); +* // returns 6.0 +* +* sum = accumulator( 1.0, -1.0 ); +* // returns 5.0 +* +* sum = accumulator( NaN, NaN ); +* // returns 5.0 +* +* sum = accumulator( 3, NaN ); +* // returns 5.0 +* +* sum = accumulator( 3.0, 4.0 ); +* // returns 17.0 +* +* sum = accumulator(); +* // returns 17.0 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.js new file mode 100644 index 000000000000..9a88aab682d0 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.js @@ -0,0 +1,78 @@ +/** +* @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 incrsumprod = require( '@stdlib/stats/incr/sumprod' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes a sum of products, ignoring NaN values. +* +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrnansumprod(); +* +* var sum = accumulator( 2.0, 3.0 ); +* // returns 6.0 +* +* sum = accumulator( 1.0, -1.0 ); +* // returns 5.0 +* +* sum = accumulator( NaN, NaN ); +* // returns 5.0 +* +* sum = accumulator( 3, NaN ); +* // returns 5.0 +* +* sum = accumulator( 3.0, 4.0 ); +* // returns 17.0 +* +* sum = accumulator(); +* // returns 17.0 +*/ +function incrnansumprod() { + var sumprod = incrsumprod(); + return accumulator; + + /** + * If provided input values, the accumulator function returns an updated sum. If not provided input values, the accumulator function returns the current sum. + * + * @private + * @param {number} [x] - first value + * @param {number} [y] - second value + * @returns {(number|null)} sum-product or null + */ + function accumulator( x, y ) { + if ( arguments.length === 0 || isnan( x ) || isnan( y ) ) { + return sumprod(); + } + return sumprod( x, y ); + } +} + + +// EXPORTS // + +module.exports = incrnansumprod; diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/package.json b/lib/node_modules/@stdlib/stats/incr/nansumprod/package.json new file mode 100644 index 000000000000..16ff407d1604 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/stats/incr/nansumprod", + "version": "0.0.0", + "description": "Compute a sum of products incrementally. 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" + } + ], + "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", + "summation", + "sum", + "total", + "product", + "prod", + "dot", + "dot product", + "sum-product", + "incremental", + "accumulator" + ] + } diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.js new file mode 100644 index 000000000000..9e3a0130c2fc --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.js @@ -0,0 +1,111 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var incrnansumprod = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrnansumprod, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.equal( typeof incrnansumprod(), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the initial accumulated value is `null`', function test( t ) { + var acc = incrnansumprod(); + t.equal( acc(), null, 'returns expected value' ); + t.end(); +}); + +tape( 'the accumulator function incrementally computes a sum of products (aka dot product), ignoring NaN values', function test( t ) { + var expected; + var actual; + var data; + var acc; + var sum; + var N; + var x; + var y; + var i; + var a; + + data = [ + [ 2.0, 3.0 ], + [ 3.0, NaN ], + [ 2.0, 5.0 ], + [ NaN, -4.0 ], + [ 3.0, 0.0 ], + [ NaN, NaN ] + ]; + N = data.length; + + expected = []; + actual = []; + for ( a = 0; a < N; a++ ) { + expected.push(undefined); + actual.push(undefined); + } + + acc = incrnansumprod(); + + sum = 0; + for ( i = 0; i < N; i++ ) { + x = data[ i ][ 0 ]; + y = data[ i ][ 1 ]; + if ( isnan( x ) === false && isnan( y ) === false ) { + sum += x * y; + } + expected[ i ] = sum; + actual[ i ] = acc( x, y ); + } + t.deepEqual( actual, expected, 'returns expected values' ); + t.end(); +}); + +tape( 'if not provided an input value, the accumulator function returns the current sum of products', function test( t ) { + var data; + var acc; + var i; + + data = [ + [ 2.0, 3.0 ], + [ 3.0, NaN ], + [ 2.0, 5.0 ], + [ NaN, -4.0 ], + [ 3.0, 0.0 ], + [ NaN, NaN ] + ]; + acc = incrnansumprod(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ][ 0 ], data[ i ][ 1 ] ); + } + t.equal( acc(), 16.0, 'returns expected value' ); + t.end(); +}); From 957184dadb8f0456ad06713119370cb6491042fb Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Wed, 2 Apr 2025 05:06:25 +0000 Subject: [PATCH 2/9] chore: update copyright years --- lib/node_modules/@stdlib/stats/incr/nansumprod/README.md | 2 +- .../@stdlib/stats/incr/nansumprod/benchmark/benchmark.js | 2 +- .../@stdlib/stats/incr/nansumprod/docs/types/index.d.ts | 2 +- .../@stdlib/stats/incr/nansumprod/docs/types/test.ts | 2 +- .../@stdlib/stats/incr/nansumprod/examples/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.js | 2 +- lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md b/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md index bbc580bd0584..1e67e5769c7d 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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. diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js index f240f8df5762..ea387dbf2b4b 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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. diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts index 4a227901b379..8f873b7f8467 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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. diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/test.ts index 1eff87cf2bd4..957fc5b1c8ab 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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. diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js index c799db24e1a5..d580d8f20c97 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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. diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js index 020d07c2c325..a1008a89d265 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/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. diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.js index 9a88aab682d0..ec2aa05606e0 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.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. diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.js index 9e3a0130c2fc..77216a31ce5e 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.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. From 5ecc812a7492e40cc3093e3c848a4faf493cb7cf Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 1 Apr 2025 22:07:41 -0700 Subject: [PATCH 3/9] style: fix indentation Signed-off-by: Athan --- .../stats/incr/nansumprod/package.json | 132 +++++++++--------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/package.json b/lib/node_modules/@stdlib/stats/incr/nansumprod/package.json index 16ff407d1604..f332659cb42e 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/package.json @@ -1,69 +1,69 @@ { - "name": "@stdlib/stats/incr/nansumprod", - "version": "0.0.0", - "description": "Compute a sum of products incrementally. Ignoring NaN values", - "license": "Apache-2.0", - "author": { + "name": "@stdlib/stats/incr/nansumprod", + "version": "0.0.0", + "description": "Compute a sum of products incrementally. 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", - "summation", - "sum", - "total", - "product", - "prod", - "dot", - "dot product", - "sum-product", - "incremental", - "accumulator" - ] - } + } + ], + "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", + "summation", + "sum", + "total", + "product", + "prod", + "dot", + "dot product", + "sum-product", + "incremental", + "accumulator" + ] +} From 6e02abcfa2847743971d57a9afe15fe7d2372842 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 20 Jul 2026 15:25:56 -0500 Subject: [PATCH 4/9] fix: address review feedback for stats/incr/nansumprod --- lib/node_modules/@stdlib/stats/incr/nansumprod/README.md | 2 +- .../@stdlib/stats/incr/nansumprod/docs/types/index.d.ts | 2 +- .../@stdlib/stats/incr/nansumprod/examples/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nansumprod/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md b/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md index 1e67e5769c7d..9c62ed5e46a3 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md @@ -20,7 +20,7 @@ limitations under the License. # incrnansumprod -> Compute a sum of products incrementally ignoring `NaN` values. +> Compute a sum of products incrementally, ignoring `NaN` values.
diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts index 8f873b7f8467..4d20c5a112ad 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts @@ -35,7 +35,7 @@ type accumulator = ( x?: number, y?: number ) => number | null; * @returns accumulator function * * @example -* var accumulator = incrsumprod(); +* var accumulator = incrnansumprod(); * * var v = accumulator(); * // returns null diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js index d580d8f20c97..54fe71e9ec48 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js @@ -44,6 +44,6 @@ for ( i = 0; i < 100; i++ ) { v2 = randu() * 100.0; } sum = accumulator( v1, v2 ); - console.log( '%d\t%d\t%d', v1.toFixed( 4 ), v2.toFixed( 4 ), sum.toFixed( 4 ) ); + console.log( '%s\t%s\t%s', ( v1 !== v1 ) ? 'NaN' : v1.toFixed( 4 ), ( v2 !== v2 ) ? 'NaN' : v2.toFixed( 4 ), ( sum === null ) ? 'null' : sum.toFixed( 4 ) ); } console.log( '\nFinal sum-product: %d\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/package.json b/lib/node_modules/@stdlib/stats/incr/nansumprod/package.json index f332659cb42e..4f2ee0e19f21 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/stats/incr/nansumprod", "version": "0.0.0", - "description": "Compute a sum of products incrementally. Ignoring NaN values", + "description": "Compute a sum of products incrementally, ignoring NaN values.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From 51fce469889f1e6e2ec7172e84355b6cb451fd9c Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Mon, 20 Jul 2026 20:56:27 +0000 Subject: [PATCH 5/9] chore: update copyright years --- lib/node_modules/@stdlib/stats/incr/nansumprod/README.md | 2 +- .../@stdlib/stats/incr/nansumprod/benchmark/benchmark.js | 2 +- .../@stdlib/stats/incr/nansumprod/docs/types/index.d.ts | 2 +- .../@stdlib/stats/incr/nansumprod/docs/types/test.ts | 2 +- .../@stdlib/stats/incr/nansumprod/examples/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.js | 2 +- lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md b/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md index 9c62ed5e46a3..2d5c51275515 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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. diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js index ea387dbf2b4b..25d236b5e439 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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/nansumprod/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts index 4d20c5a112ad..1dfde894d61b 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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. diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/test.ts index 957fc5b1c8ab..d9b1effa4bae 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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/nansumprod/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js index 54fe71e9ec48..23161e49b7d2 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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. diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js index a1008a89d265..c53127f7bdb2 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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/nansumprod/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.js index ec2aa05606e0..a779dfa4a59c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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/nansumprod/test/test.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.js index 77216a31ce5e..fea8378ac9d3 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/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. From 8a9bcc5abfc99c8319a65b57608a1a529f0da54e Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 20 Jul 2026 16:06:09 -0500 Subject: [PATCH 6/9] fix: use format() for benchmark descriptions in stats/incr/nansumprod --- .../@stdlib/stats/incr/nansumprod/benchmark/benchmark.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js index 25d236b5e439..29edbf27b6bc 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/benchmark/benchmark.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var randu = require( '@stdlib/random/base/randu' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var incrnansumprod = require( './../lib' ); @@ -46,7 +47,7 @@ bench( pkg, function benchmark( b ) { b.end(); }); -bench( pkg+'::accumulator', function benchmark( b ) { +bench( format( '%s::accumulator', pkg ), function benchmark( b ) { var acc; var v; var i; @@ -55,7 +56,7 @@ bench( pkg+'::accumulator', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = acc( randu()*10.0, randu()*10.0 ); + v = acc( randu() * 10.0, randu() * 10.0 ); if ( v !== v ) { b.fail( 'should not return NaN' ); } From 11139e9875b7cfcdc46d24d8065ba8826d29e6b2 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 20 Jul 2026 16:24:05 -0500 Subject: [PATCH 7/9] fix: add missing comma in lib/index.js description for stats/incr/nansumprod --- lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js index c53127f7bdb2..20edff968a0f 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Compute a sum of products incrementally ignoring `NaN` values. +* Compute a sum of products incrementally, ignoring `NaN` values. * * @module @stdlib/stats/incr/nansumprod * From 4c20d7090278477bbc9d254248a5a1a2eb1b23d8 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 20 Jul 2026 16:53:49 -0500 Subject: [PATCH 8/9] fix: use isnan instead of negated condition in examples --- .../@stdlib/stats/incr/nansumprod/examples/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js index 23161e49b7d2..c30682f62ab2 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js @@ -18,6 +18,7 @@ 'use strict'; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); var randu = require( '@stdlib/random/base/randu' ); var incrnansumprod = require( './../lib' ); @@ -44,6 +45,6 @@ for ( i = 0; i < 100; i++ ) { v2 = randu() * 100.0; } sum = accumulator( v1, v2 ); - console.log( '%s\t%s\t%s', ( v1 !== v1 ) ? 'NaN' : v1.toFixed( 4 ), ( v2 !== v2 ) ? 'NaN' : v2.toFixed( 4 ), ( sum === null ) ? 'null' : sum.toFixed( 4 ) ); + console.log( '%s\t%s\t%s', isnan( v1 ) ? 'NaN' : v1.toFixed( 4 ), isnan( v2 ) ? 'NaN' : v2.toFixed( 4 ), ( sum === null ) ? 'null' : sum.toFixed( 4 ) ); } console.log( '\nFinal sum-product: %d\n', accumulator() ); From 1e6abf358f8bd040ffc181bd1d7d5e91e5e02dfe Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 20 Jul 2026 17:15:43 -0500 Subject: [PATCH 9/9] fix: add parentheses around ternary conditions in examples --- .../@stdlib/stats/incr/nansumprod/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js index c30682f62ab2..c1eeccf250db 100644 --- a/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nansumprod/examples/index.js @@ -45,6 +45,6 @@ for ( i = 0; i < 100; i++ ) { v2 = randu() * 100.0; } sum = accumulator( v1, v2 ); - console.log( '%s\t%s\t%s', isnan( v1 ) ? 'NaN' : v1.toFixed( 4 ), isnan( v2 ) ? 'NaN' : v2.toFixed( 4 ), ( sum === null ) ? 'null' : sum.toFixed( 4 ) ); + console.log( '%s\t%s\t%s', ( isnan( v1 ) ) ? 'NaN' : v1.toFixed( 4 ), ( isnan( v2 ) ) ? 'NaN' : v2.toFixed( 4 ), ( sum === null ) ? 'null' : sum.toFixed( 4 ) ); } console.log( '\nFinal sum-product: %d\n', accumulator() );