From f93ecb8bae00cfeaf32b102325a77309173350a5 Mon Sep 17 00:00:00 2001 From: Aly Date: Wed, 26 Mar 2025 06:09:30 +0200 Subject: [PATCH 1/3] add: add nanminmaxabs module in the incr directory --- .../@stdlib/stats/incr/nanminmaxabs/README.md | 160 +++++++++++ .../incr/nanminmaxabs/benchmark/benchmark.js | 72 +++++ .../stats/incr/nanminmaxabs/docs/repl.txt | 39 +++ .../incr/nanminmaxabs/docs/types/index.d.ts | 69 +++++ .../incr/nanminmaxabs/docs/types/tests.ts | 61 +++++ .../stats/incr/nanminmaxabs/examples/index.js | 47 ++++ .../stats/incr/nanminmaxabs/lib/index.js | 64 +++++ .../stats/incr/nanminmaxabs/lib/main.js | 74 +++++ .../stats/incr/nanminmaxabs/package.json | 74 +++++ .../stats/incr/nanminmaxabs/test/test.js | 259 ++++++++++++++++++ 10 files changed, 919 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/incr/nanminmaxabs/README.md create mode 100644 lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/tests.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanminmaxabs/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanminmaxabs/package.json create mode 100644 lib/node_modules/@stdlib/stats/incr/nanminmaxabs/test/test.js diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/README.md b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/README.md new file mode 100644 index 000000000000..abe785a09a32 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/README.md @@ -0,0 +1,160 @@ + + +# incrnanminmaxabs + +> Compute minimum and maximum absolute values incrementally, ignoring `NaN` values. + +
+ +## Usage + +```javascript +var incrnanminmaxabs = require( '@stdlib/stats/incr/nanminmaxabs' ); +``` + +#### incrnanminmaxabs( \[out] ) + +Returns an accumulator `function` which incrementally computes minimum and maximum absolute values while ignoring `NaN` values. + +```javascript +var accumulator = incrnanminmaxabs(); +``` + +By default, the returned accumulator `function` returns the minimum and maximum absolute values as a two-element `array`. To avoid unnecessary memory allocation, the function supports providing an output (destination) object. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var accumulator = incrnanminmaxabs( new Float64Array( 2 ) ); +``` + +#### accumulator( \[x] ) + +If provided an input value `x`, the accumulator function returns updated minimum and maximum absolute values, ignoring `NaN`. If not provided an input value `x`, the accumulator function returns the current minimum and maximum absolute values. + +```javascript +var accumulator = incrnanminmaxabs(); + +var mm = accumulator(); +// returns null + +mm = accumulator( 2.0 ); +// returns [ 2.0, 2.0 ] + +mm = accumulator( NaN ); +// returns [ 2.0, 2.0 ] (ignores NaN) + +mm = accumulator( 1.0 ); +// returns [ 1.0, 2.0 ] + +mm = accumulator( 3.0 ); +// returns [ 1.0, 3.0 ] + +mm = accumulator( -7.0 ); +// returns [ 1.0, 7.0 ] + +mm = accumulator(); +// returns [ 1.0, 7.0 ] +``` + +
+ + + +
+ +## Notes + +- `NaN` values are ignored in calculations. This ensures `NaN` does not contaminate future results. +- If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function. + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var incrnanminmaxabs = require( '@stdlib/stats/incr/nanminmaxabs' ); + +var accumulator; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanminmaxabs(); + +// For each simulated datum, update the minimum and maximum absolute values... +for ( i = 0; i < 100; i++ ) { + v = ( randu()*100.0 ) - 50.0; + if ( randu() < 0.1 ) { + v = NaN; + } + accumulator( v ); +} +console.log( accumulator() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js new file mode 100644 index 000000000000..64b5c35cc3a3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js @@ -0,0 +1,72 @@ +/** + * @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 isnan = require("@stdlib/math/base/assert/is-nan"); +var pkg = require("./../package.json").name; +var incrnanminmaxabs = require("./../lib"); + +// MAIN // + +bench(pkg, function benchmark(b) { + var f; + var i; + b.tic(); + for (i = 0; i < b.iterations; i++) { + f = incrnanminmaxabs(); + 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 = incrnanminmaxabs(); + + b.tic(); + for (i = 0; i < b.iterations; i++) { + v = randu() > 0.1 ? randu() - 0.5 : NaN; // Introduce some NaNs + acc(v); + } + v = acc(); + b.toc(); + + // Ensure NaN values are ignored unless all inputs were NaN + if (isnan(v[0]) && isnan(v[1]) && i > 0) { + b.fail("should not return NaN unless all inputs were NaN"); + } + + b.pass("benchmark finished"); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/repl.txt new file mode 100644 index 000000000000..43e7e10cfb94 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/repl.txt @@ -0,0 +1,39 @@ +{{alias}}( [out] ) + Returns an accumulator function which incrementally computes a minimum and + maximum absolute value. + + If provided a value, the accumulator function returns an updated minimum and + maximum. If not provided a value, the accumulator function returns the + current minimum and maximum. + + If provided `NaN`, the accumulator ignores it and does not update the + minimum or maximum values. + + Parameters + ---------- + out: Array|TypedArray (optional) + Output array. + + Returns + ------- + acc: Function + Accumulator function. + + Examples + -------- + > var accumulator = {{alias}}(); + > var mm = accumulator(); + null + > mm = accumulator( 2.0 ); + [ 2, 2 ] + > mm = accumulator( -5.0 ); + [ 2, 5 ] + > mm = accumulator( 3.0 ); + [ 2, 5 ] + > mm = accumulator( 5.0 ); + [ 2, 5 ] + > mm = accumulator(); + [ 2, 5 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/index.d.ts new file mode 100644 index 000000000000..57befb1c757f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/index.d.ts @@ -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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { ArrayLike } from '@stdlib/types/array'; + +/** +* If provided a value, the accumulator function returns updated absolute minimum and maximum values. If not provided a value, the accumulator function returns the current minimum and maximum values. +* +* ## Notes +* +* - If provided `NaN`, the minimum and maximum values are equal to `NaN` for all future invocations. +* +* @param x - input value +* @returns output array or null +*/ +type accumulator = ( x?: number ) => ArrayLike | null; + +/** +* Returns an accumulator function which incrementally computes minimum and maximum absolute values. +* +* @param out - output array +* @returns accumulator function +* +* @example +* var accumulator = incrnanminmaxabs(); +* +* var mm = accumulator(); +* // returns null +* +* mm = accumulator( 2.0 ); +* // returns [ 2.0, 2.0 ] +* +* mm = accumulator( -5.0 ); +* // returns [ 2.0, 5.0 ] +* +* mm = accumulator( 3.0 ); +* // returns [ 2.0, 5.0 ] +* +* mm = accumulator( 5.0 ); +* // returns [ 2.0, 5.0 ] +* +* mm = accumulator(); +* // returns [ 2.0, 5.0 ] +*/ +declare function incrnanminmaxabs( out?: ArrayLike ): accumulator; + + +// EXPORTS // + +export = incrnanminmaxabs; diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/tests.ts b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/tests.ts new file mode 100644 index 000000000000..9ca4cb2e7b5b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/tests.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 incrnanminmaxabs from './index'; + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnanminmaxabs(); // $ExpectType accumulator + const out = [ 0.0, 0.0 ]; + incrnanminmaxabs( out ); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided an argument that is not an array-like object of numbers... +{ + incrnanminmaxabs( '5' ); // $ExpectError + incrnanminmaxabs( 5 ); // $ExpectError + incrnanminmaxabs( true ); // $ExpectError + incrnanminmaxabs( false ); // $ExpectError + incrnanminmaxabs( null ); // $ExpectError + incrnanminmaxabs( {} ); // $ExpectError + incrnanminmaxabs( ( x: number ): number => x ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnanminmaxabs(); + + acc(); // $ExpectType ArrayLike | null + acc( 3.14 ); // $ExpectType ArrayLike | null +} + +// The compiler throws an error if the returned accumulator function is provided invalid arguments... +{ + const acc = incrnanminmaxabs(); + + 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/nanminmaxabs/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/examples/index.js new file mode 100644 index 000000000000..aa7ca0c8d6e3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/examples/index.js @@ -0,0 +1,47 @@ +/** + * @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 incrnanminmaxabs = require("./../lib"); + +var accumulator; +var mm; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanminmaxabs(); + +// For each simulated datum, update the minimum and maximum absolute values... +console.log("\nValue\tMin\tMax\n"); +for (i = 0; i < 100; i++) { + v = randu() * 100.0 - 50.0; + // Introduce NaN values randomly + if (randu() < 0.1) { + v = NaN; + } + mm = accumulator(v); + console.log( + "%d\t%d\t%d", + isNaN(v) ? "NaN" : v.toFixed(3), + mm[0].toFixed(3), + mm[1].toFixed(3) + ); +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/index.js new file mode 100644 index 000000000000..5292130fa4ef --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/index.js @@ -0,0 +1,64 @@ +/** + * @module @stdlib/stats/incr/nanminmaxabs + * @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 minimum and maximum absolute values incrementally, ignoring NaN values. +/** + * Compute minimum and maximum absolute values incrementally, **ignoring NaN values**. + * + * @module @stdlib/stats/incr/nanminmaxabs + * + * @example + * var incrnanminmaxabs = require( '@stdlib/stats/incr/nanminmaxabs' ); + * + * var accumulator = incrnanminmaxabs(); + * + * var mm = accumulator(); + * // returns null + * + * mm = accumulator( 2.0 ); + * // returns [ 2.0, 2.0 ] + * + * mm = accumulator( NaN ); + * // returns [ 2.0, 2.0 ] (ignores NaN) + * + * mm = accumulator( -5.0 ); + * // returns [ 2.0, 5.0 ] + * + * mm = accumulator( 3.0 ); + * // returns [ 2.0, 5.0 ] + * + * mm = accumulator( NaN ); + * // returns [ 2.0, 5.0 ] (still ignores NaN) + * + * mm = accumulator(); + * // returns [ 2.0, 5.0 ] + */ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; + diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/main.js new file mode 100644 index 000000000000..4dedba3be767 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/main.js @@ -0,0 +1,74 @@ +/** + * @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 incrminmaxabs = require("@stdlib/stats/incr/minmaxabs"); +var isnan = require("@stdlib/math/base/assert/is-nan"); +var isArrayLike = require("@stdlib/assert/is-array-like"); + +/** + * Returns an accumulator function which incrementally computes minimum and maximum absolute values, ignoring NaNs. + * + * @module @stdlib/stats/incr/nanminmaxabs + * @param {Collection} [out] - output array + * @returns {Function} accumulator function + * @throws {TypeError} if out is not an array-like object + * + * @example + * var accumulator = incrnanminmaxabs(); + * + * var mm = accumulator(); + * // returns null + * + * mm = accumulator( NaN ); + * // returns null + * + * mm = accumulator( 2.0 ); + * // returns [ 2.0, 2.0 ] + * + * mm = accumulator( NaN ); + * // returns [ 2.0, 2.0 ] + * + * mm = accumulator( -5.0 ); + * // returns [ 2.0, 5.0 ] + */ +function incrnanminmaxabs(out) { + if (arguments.length > 0 && !isArrayLike(out)) { + throw new TypeError( + "invalid argument. Output argument must be an array-like object." + ); + } + var accumulator = incrminmaxabs(out || []); + var hasValues = false; + + return function (x) { + if (arguments.length === 0) { + return hasValues ? accumulator() : null; + } + if (isnan(x)) { + return hasValues ? accumulator() : null; + } + hasValues = true; + return accumulator(x); + }; +} + +// EXPORTS // +module.exports = incrnanminmaxabs; diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/package.json b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/package.json new file mode 100644 index 000000000000..e255d07b0ac9 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/stats/incr/nanminmaxabs", + "version": "0.0.0", + "description": "Compute minimum and maximum absolute values incrementally, ignoring NaNs.", + "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", + "minimum", + "min", + "absolute", + "value", + "abs", + "math.abs", + "range", + "extent", + "extrema", + "incremental", + "accumulator", + "nan", + "ignore-nans" + ] + } diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/test/test.js new file mode 100644 index 000000000000..40c5f86e28d9 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/test/test.js @@ -0,0 +1,259 @@ +/** + * @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 tape = require("tape"); +var isPositiveZero = require("@stdlib/math/base/assert/is-positive-zero"); +var isnan = require("@stdlib/math/base/assert/is-nan"); +var incrnanminmaxabs = require("./../lib"); + +// TESTS // + +tape("main export is a function", function test(t) { + t.ok(true, __filename); + t.strictEqual( + typeof incrnanminmaxabs, + "function", + "main export is a function" + ); + t.end(); +}); + +tape( + "the function throws an error if not provided an array-like object for an output argument", + function test(t) { + var values; + var i; + + values = [ + "5", + -5.0, + true, + false, + null, + void 0, + NaN, + {}, + function noop() {}, + ]; + + for (i = 0; i < values.length; i++) { + t.throws( + badValue(values[i]), + TypeError, + "throws an error when provided " + values[i] + ); + } + t.end(); + + function badValue(value) { + return function badValue() { + incrnanminmaxabs(value); + }; + } + } +); + +tape("the function returns an accumulator function", function test(t) { + t.equal(typeof incrnanminmaxabs(), "function", "returns a function"); + t.end(); +}); + +tape("the function returns an accumulator function (output)", function test(t) { + t.equal( + typeof incrnanminmaxabs([0.0, 0.0]), + "function", + "returns a function" + ); + t.end(); +}); + +tape( + "the accumulator function computes a minimum and maximum absolute value incrementally", + function test(t) { + var expected; + var actual; + var data; + var acc; + var N; + var i; + + data = [ + 2.0, -3.0, -2.0, 4.0, -3.0, -4.0, -2.0, 2.0, -2.0, 1.0, -0.0, 4.0, -1.0, + ]; + N = data.length; + + acc = incrnanminmaxabs(); + + actual = []; + for (i = 0; i < N; i++) { + actual.push(acc(data[i]).slice()); + } + expected = [ + [2.0, 2.0], + [2.0, 3.0], + [2.0, 3.0], + [2.0, 4.0], + [2.0, 4.0], + [2.0, 4.0], + [2.0, 4.0], + [2.0, 4.0], + [2.0, 4.0], + [1.0, 4.0], + [0.0, 4.0], + [0.0, 4.0], + [0.0, 4.0], + ]; + + t.deepEqual(actual, expected, "returns expected values"); + t.end(); + } +); + +tape( + "the accumulator function computes a minimum and maximum absolute value incrementally (output)", + function test(t) { + var expected; + var actual; + var data; + var acc; + var out; + var N; + var i; + + data = [ + 2.0, -3.0, -2.0, 4.0, -3.0, -4.0, -2.0, 2.0, -2.0, 1.0, -0.0, 4.0, -1.0, + ]; + N = data.length; + + out = [0.0, 0.0]; + acc = incrnanminmaxabs(out); + + actual = []; + for (i = 0; i < N; i++) { + actual.push(acc(data[i])); + t.equal(actual[i], out, "returns output array"); + actual[i] = actual[i].slice(); + } + expected = [ + [2.0, 2.0], + [2.0, 3.0], + [2.0, 3.0], + [2.0, 4.0], + [2.0, 4.0], + [2.0, 4.0], + [2.0, 4.0], + [2.0, 4.0], + [2.0, 4.0], + [1.0, 4.0], + [0.0, 4.0], + [0.0, 4.0], + [0.0, 4.0], + ]; + + t.deepEqual(actual, expected, "returns expected values"); + t.end(); + } +); + +tape( + "if not provided an input value, the accumulator function returns the current minimum and maximum absolute values", + function test(t) { + var data; + var acc; + var i; + + data = [2.0, -3.0, -5.0, 4.0]; + acc = incrnanminmaxabs(); + for (i = 0; i < data.length; i++) { + acc(data[i]); + } + t.deepEqual(acc(), [2.0, 5.0], "returns expected value"); + t.end(); + } +); + +tape( + "if data has yet to be provided, the accumulator function returns `null`", + function test(t) { + var acc = incrnanminmaxabs(); + t.equal(acc(), null, "returns null"); + t.end(); + } +); + +tape( + "the accumulator function correctly handles signed zeros", + function test(t) { + var acc; + var v; + + acc = incrnanminmaxabs(); + + v = acc(0.0); + t.equal(isPositiveZero(v[0]), true, "returns expected value"); + t.equal(isPositiveZero(v[1]), true, "returns expected value"); + + v = acc(-0.0); + t.equal(isPositiveZero(v[0]), true, "returns expected value"); + t.equal(isPositiveZero(v[1]), true, "returns expected value"); + + v = acc(0.0); + t.equal(isPositiveZero(v[0]), true, "returns expected value"); + t.equal(isPositiveZero(v[1]), true, "returns expected value"); + + acc = incrnanminmaxabs(); + + v = acc(-0.0); + t.equal(isPositiveZero(v[0]), true, "returns expected value"); + t.equal(isPositiveZero(v[1]), true, "returns expected value"); + + v = acc(0.0); + t.equal(isPositiveZero(v[0]), true, "returns expected value"); + t.equal(isPositiveZero(v[1]), true, "returns expected value"); + + v = acc(-0.0); + t.equal(isPositiveZero(v[0]), true, "returns expected value"); + t.equal(isPositiveZero(v[1]), true, "returns expected value"); + + t.end(); + } +); + +tape( + "if provided `NaN`, the accumulator ignores it and continues computing min/max absolute values", + function test(t) { + var data; + var acc; + var v; + var i; + + data = [2.0, NaN, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]; + acc = incrnanminmaxabs(); // Ensure this calls your new implementation + for (i = 0; i < data.length; i++) { + acc(data[i]); + } + v = acc(); + t.equal(v[0], 1.0, "returns expected minimum absolute value"); + t.equal(v[1], 7.0, "returns expected maximum absolute value"); + t.end(); + } +); From a4c45c97fc933205b70f99275b3adbd44116db5f Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 18 Jul 2026 13:33:12 -0500 Subject: [PATCH 2/3] fix: address lint errors --- .../@stdlib/stats/incr/nanminmaxabs/README.md | 44 +- .../incr/nanminmaxabs/benchmark/benchmark.js | 91 ++-- .../stats/incr/nanminmaxabs/docs/repl.txt | 34 +- .../incr/nanminmaxabs/docs/types/index.d.ts | 12 +- .../docs/types/{tests.ts => test.ts} | 2 +- .../stats/incr/nanminmaxabs/examples/index.js | 71 ++- .../stats/incr/nanminmaxabs/lib/index.js | 93 ++-- .../stats/incr/nanminmaxabs/lib/main.js | 137 +++--- .../stats/incr/nanminmaxabs/package.json | 140 +++--- .../stats/incr/nanminmaxabs/test/test.js | 457 +++++++++--------- 10 files changed, 536 insertions(+), 545 deletions(-) rename lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/{tests.ts => test.ts} (97%) diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/README.md b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/README.md index abe785a09a32..a841a1206ac1 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/README.md @@ -32,13 +32,13 @@ var incrnanminmaxabs = require( '@stdlib/stats/incr/nanminmaxabs' ); #### incrnanminmaxabs( \[out] ) -Returns an accumulator `function` which incrementally computes minimum and maximum absolute values while ignoring `NaN` values. +Returns an accumulator function which incrementally computes minimum and maximum absolute values, ignoring `NaN` values. ```javascript var accumulator = incrnanminmaxabs(); ``` -By default, the returned accumulator `function` returns the minimum and maximum absolute values as a two-element `array`. To avoid unnecessary memory allocation, the function supports providing an output (destination) object. +By default, the returned accumulator function returns the minimum and maximum absolute values as a two-element `array`. To avoid unnecessary memory allocation, the function supports providing an output (destination) object. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -48,7 +48,7 @@ var accumulator = incrnanminmaxabs( new Float64Array( 2 ) ); #### accumulator( \[x] ) -If provided an input value `x`, the accumulator function returns updated minimum and maximum absolute values, ignoring `NaN`. If not provided an input value `x`, the accumulator function returns the current minimum and maximum absolute values. +If provided an input value `x`, the accumulator function returns updated minimum and maximum absolute values. If not provided an input value `x`, the accumulator function returns the current minimum and maximum absolute values. ```javascript var accumulator = incrnanminmaxabs(); @@ -60,7 +60,7 @@ mm = accumulator( 2.0 ); // returns [ 2.0, 2.0 ] mm = accumulator( NaN ); -// returns [ 2.0, 2.0 ] (ignores NaN) +// returns [ 2.0, 2.0 ] mm = accumulator( 1.0 ); // returns [ 1.0, 2.0 ] @@ -83,8 +83,7 @@ mm = accumulator(); ## Notes -- `NaN` values are ignored in calculations. This ensures `NaN` does not contaminate future results. -- If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function. +- Input values are **not** type checked. If provided `NaN`, the value is **ignored** and does **not** affect the accumulated result. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function. @@ -97,23 +96,17 @@ mm = accumulator(); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var incrnanminmaxabs = require( '@stdlib/stats/incr/nanminmaxabs' ); -var accumulator; -var v; -var i; - // Initialize an accumulator: -accumulator = incrnanminmaxabs(); +var accumulator = incrnanminmaxabs(); // For each simulated datum, update the minimum and maximum absolute values... +var i; for ( i = 0; i < 100; i++ ) { - v = ( randu()*100.0 ) - 50.0; - if ( randu() < 0.1 ) { - v = NaN; - } - accumulator( v ); + accumulator( ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -50.0, 50.0 ) ); } console.log( accumulator() ); ``` @@ -126,15 +119,6 @@ console.log( accumulator() ); @@ -145,14 +129,6 @@ console.log( accumulator() ); -[@stdlib/stats/incr/maxabs]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/maxabs - -[@stdlib/stats/incr/minabs]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/minabs - -[@stdlib/stats/incr/minmax]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/minmax - -[@stdlib/stats/incr/mminmaxabs]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/mminmaxabs - diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js index 64b5c35cc3a3..5ef5af543ae9 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js @@ -1,72 +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. - */ +* @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"; +'use strict'; // MODULES // -var bench = require("@stdlib/bench"); -var randu = require("@stdlib/random/base/randu"); -var isnan = require("@stdlib/math/base/assert/is-nan"); -var pkg = require("./../package.json").name; -var incrnanminmaxabs = require("./../lib"); +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var incrnanminmaxabs = require( './../lib' ); + // MAIN // -bench(pkg, function benchmark(b) { +bench( pkg, function benchmark( b ) { var f; var i; b.tic(); - for (i = 0; i < b.iterations; i++) { + for ( i = 0; i < b.iterations; i++ ) { f = incrnanminmaxabs(); - if (typeof f !== "function") { - b.fail("should return a function"); + if ( typeof f !== 'function' ) { + b.fail( 'should return a function' ); } } b.toc(); - if (typeof f !== "function") { - b.fail("should return a function"); + if ( typeof f !== 'function' ) { + b.fail( 'should return a function' ); } - b.pass("benchmark finished"); + b.pass( 'benchmark finished' ); b.end(); }); -bench(pkg + "::accumulator", function benchmark(b) { +bench( format( '%s::accumulator', pkg ), function benchmark( b ) { var acc; + var x; var v; var i; acc = incrnanminmaxabs(); + x = new Float64Array( b.iterations ); + for ( i = 0; i < b.iterations; i++ ) { + if ( ( i & 7 ) === 7 ) { + x[ i ] = NaN; + } else { + x[ i ] = uniform( -100.0, 100.0 ); + } + } + b.tic(); - for (i = 0; i < b.iterations; i++) { - v = randu() > 0.1 ? randu() - 0.5 : NaN; // Introduce some NaNs - acc(v); + for ( i = 0; i < b.iterations; i++ ) { + v = acc( x[ i ] ); + if ( v !== null && v.length !== 2 ) { + b.fail( 'should contain two elements' ); + } } - v = acc(); b.toc(); - - // Ensure NaN values are ignored unless all inputs were NaN - if (isnan(v[0]) && isnan(v[1]) && i > 0) { - b.fail("should not return NaN unless all inputs were NaN"); + if ( v[ 0 ] !== v[ 0 ] || v[ 1 ] !== v[ 1 ] ) { + b.fail( 'should not return NaN' ); } - - b.pass("benchmark finished"); + b.pass( 'benchmark finished' ); b.end(); }); diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/repl.txt index 43e7e10cfb94..fea5d1196e96 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/repl.txt @@ -1,13 +1,14 @@ + {{alias}}( [out] ) Returns an accumulator function which incrementally computes a minimum and - maximum absolute value. + maximum absolute value, ignoring `NaN` values. - If provided a value, the accumulator function returns an updated minimum and - maximum. If not provided a value, the accumulator function returns the + If provided a value, the accumulator function returns an updated minimum + and maximum. If not provided a value, the accumulator function returns the current minimum and maximum. - If provided `NaN`, the accumulator ignores it and does not update the - minimum or maximum values. + Any `NaN` values provided to the accumulator are ignored, and do not + affect the accumulated result. Parameters ---------- @@ -22,18 +23,19 @@ Examples -------- > var accumulator = {{alias}}(); - > var mm = accumulator(); + > var mm = accumulator() null - > mm = accumulator( 2.0 ); - [ 2, 2 ] - > mm = accumulator( -5.0 ); - [ 2, 5 ] - > mm = accumulator( 3.0 ); - [ 2, 5 ] - > mm = accumulator( 5.0 ); - [ 2, 5 ] - > mm = accumulator(); - [ 2, 5 ] + > mm = accumulator( 2.0 ) + [ 2.0, 2.0 ] + > mm = accumulator( NaN ) + [ 2.0, 2.0 ] + > mm = accumulator( -5.0 ) + [ 2.0, 5.0 ] + > mm = accumulator( 3.0 ) + [ 2.0, 5.0 ] + > mm = accumulator() + [ 2.0, 5.0 ] See Also -------- + diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/index.d.ts index 57befb1c757f..11e4a627cd7b 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/index.d.ts @@ -23,11 +23,11 @@ import { ArrayLike } from '@stdlib/types/array'; /** -* If provided a value, the accumulator function returns updated absolute minimum and maximum values. If not provided a value, the accumulator function returns the current minimum and maximum values. +* If provided a value, the accumulator function returns updated minimum and maximum absolute values. If not provided a value, the accumulator function returns the current minimum and maximum absolute values. * * ## Notes * -* - If provided `NaN`, the minimum and maximum values are equal to `NaN` for all future invocations. +* - If provided `NaN`, the value is ignored and does not affect the accumulated result. * * @param x - input value * @returns output array or null @@ -35,7 +35,7 @@ import { ArrayLike } from '@stdlib/types/array'; type accumulator = ( x?: number ) => ArrayLike | null; /** -* Returns an accumulator function which incrementally computes minimum and maximum absolute values. +* Returns an accumulator function which incrementally computes minimum and maximum absolute values, ignoring `NaN` values. * * @param out - output array * @returns accumulator function @@ -49,15 +49,15 @@ type accumulator = ( x?: number ) => ArrayLike | null; * mm = accumulator( 2.0 ); * // returns [ 2.0, 2.0 ] * +* mm = accumulator( NaN ); +* // returns [ 2.0, 2.0 ] +* * mm = accumulator( -5.0 ); * // returns [ 2.0, 5.0 ] * * mm = accumulator( 3.0 ); * // returns [ 2.0, 5.0 ] * -* mm = accumulator( 5.0 ); -* // returns [ 2.0, 5.0 ] -* * mm = accumulator(); * // returns [ 2.0, 5.0 ] */ diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/tests.ts b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/test.ts similarity index 97% rename from lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/tests.ts rename to lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/test.ts index 9ca4cb2e7b5b..340395315818 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/tests.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/test.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -import incrnanminmaxabs from './index'; +import incrnanminmaxabs = require( './index' ); // TESTS // diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/examples/index.js index aa7ca0c8d6e3..7e99a466a6ef 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/examples/index.js @@ -1,47 +1,42 @@ /** - * @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. - */ +* @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"; +'use strict'; -var randu = require("@stdlib/random/base/randu"); -var incrnanminmaxabs = require("./../lib"); - -var accumulator; -var mm; -var v; -var i; +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var incrnanminmaxabs = require( './../lib' ); // Initialize an accumulator: -accumulator = incrnanminmaxabs(); +var accumulator = incrnanminmaxabs(); // For each simulated datum, update the minimum and maximum absolute values... -console.log("\nValue\tMin\tMax\n"); -for (i = 0; i < 100; i++) { - v = randu() * 100.0 - 50.0; - // Introduce NaN values randomly - if (randu() < 0.1) { - v = NaN; +console.log( '\nValue\tMin\tMax\n' ); +var mm; +var v; +var i; +for ( i = 0; i < 100; i++ ) { + v = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -50.0, 50.0 ); + mm = accumulator( v ); + if ( mm === null ) { + console.log( '%d\t--\t--', v.toFixed( 3 ) ); + } else { + console.log( '%d\t%d\t%d', v.toFixed( 3 ), mm[ 0 ].toFixed( 3 ), mm[ 1 ].toFixed( 3 ) ); } - mm = accumulator(v); - console.log( - "%d\t%d\t%d", - isNaN(v) ? "NaN" : v.toFixed(3), - mm[0].toFixed(3), - mm[1].toFixed(3) - ); } +console.log( '\nFinal min/max: %s\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/index.js index 5292130fa4ef..4a5bb831c2e9 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/index.js @@ -1,57 +1,51 @@ /** - * @module @stdlib/stats/incr/nanminmaxabs - * @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. - */ +* @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 minimum and maximum absolute values incrementally, ignoring NaN values. -/** - * Compute minimum and maximum absolute values incrementally, **ignoring NaN values**. - * - * @module @stdlib/stats/incr/nanminmaxabs - * - * @example - * var incrnanminmaxabs = require( '@stdlib/stats/incr/nanminmaxabs' ); - * - * var accumulator = incrnanminmaxabs(); - * - * var mm = accumulator(); - * // returns null - * - * mm = accumulator( 2.0 ); - * // returns [ 2.0, 2.0 ] - * - * mm = accumulator( NaN ); - * // returns [ 2.0, 2.0 ] (ignores NaN) - * - * mm = accumulator( -5.0 ); - * // returns [ 2.0, 5.0 ] - * - * mm = accumulator( 3.0 ); - * // returns [ 2.0, 5.0 ] - * - * mm = accumulator( NaN ); - * // returns [ 2.0, 5.0 ] (still ignores NaN) - * - * mm = accumulator(); - * // returns [ 2.0, 5.0 ] - */ +* Compute minimum and maximum absolute values incrementally, ignoring `NaN` values. +* +* @module @stdlib/stats/incr/nanminmaxabs +* +* @example +* var incrnanminmaxabs = require( '@stdlib/stats/incr/nanminmaxabs' ); +* +* var accumulator = incrnanminmaxabs(); +* +* var mm = accumulator(); +* // returns null +* +* mm = accumulator( 2.0 ); +* // returns [ 2.0, 2.0 ] +* +* mm = accumulator( NaN ); +* // returns [ 2.0, 2.0 ] +* +* mm = accumulator( -5.0 ); +* // returns [ 2.0, 5.0 ] +* +* mm = accumulator( 3.0 ); +* // returns [ 2.0, 5.0 ] +* +* mm = accumulator(); +* // returns [ 2.0, 5.0 ] +*/ // MODULES // @@ -61,4 +55,3 @@ var main = require( './main.js' ); // EXPORTS // module.exports = main; - diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/main.js index 4dedba3be767..99261cb83669 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/main.js @@ -1,74 +1,89 @@ /** - * @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. - */ +* @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"; +'use strict'; // MODULES // -var incrminmaxabs = require("@stdlib/stats/incr/minmaxabs"); -var isnan = require("@stdlib/math/base/assert/is-nan"); -var isArrayLike = require("@stdlib/assert/is-array-like"); + +var isArrayLike = require( '@stdlib/assert/is-array-like-object' ); +var incrminmaxabs = require( '@stdlib/stats/incr/minmaxabs' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // /** - * Returns an accumulator function which incrementally computes minimum and maximum absolute values, ignoring NaNs. - * - * @module @stdlib/stats/incr/nanminmaxabs - * @param {Collection} [out] - output array - * @returns {Function} accumulator function - * @throws {TypeError} if out is not an array-like object - * - * @example - * var accumulator = incrnanminmaxabs(); - * - * var mm = accumulator(); - * // returns null - * - * mm = accumulator( NaN ); - * // returns null - * - * mm = accumulator( 2.0 ); - * // returns [ 2.0, 2.0 ] - * - * mm = accumulator( NaN ); - * // returns [ 2.0, 2.0 ] - * - * mm = accumulator( -5.0 ); - * // returns [ 2.0, 5.0 ] - */ -function incrnanminmaxabs(out) { - if (arguments.length > 0 && !isArrayLike(out)) { - throw new TypeError( - "invalid argument. Output argument must be an array-like object." - ); +* Returns an accumulator function which incrementally computes minimum and maximum absolute values, ignoring `NaN` values. +* +* @param {Collection} [out] - output array +* @throws {TypeError} output argument must be array-like +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrnanminmaxabs(); +* +* var mm = accumulator(); +* // returns null +* +* mm = accumulator( 2.0 ); +* // returns [ 2.0, 2.0 ] +* +* mm = accumulator( NaN ); +* // returns [ 2.0, 2.0 ] +* +* mm = accumulator( -5.0 ); +* // returns [ 2.0, 5.0 ] +* +* mm = accumulator( 3.0 ); +* // returns [ 2.0, 5.0 ] +* +* mm = accumulator(); +* // returns [ 2.0, 5.0 ] +*/ +function incrnanminmaxabs( out ) { + var minmax; + if ( arguments.length === 0 ) { + minmax = incrminmaxabs(); + } else { + if ( !isArrayLike( out ) ) { + throw new TypeError( format( 'invalid argument. Output argument must be an array-like object. Value: `%s`.', out ) ); + } + minmax = incrminmaxabs( out ); } - var accumulator = incrminmaxabs(out || []); - var hasValues = false; + return accumulator; - return function (x) { - if (arguments.length === 0) { - return hasValues ? accumulator() : null; + /** + * If provided a value, the accumulator function returns updated minimum and maximum absolute values. If not provided a value, the accumulator function returns the current minimum and maximum absolute values. + * + * @private + * @param {number} [x] - input value + * @returns {(ArrayLikeObject|null)} output array or null + */ + function accumulator( x ) { + if ( arguments.length === 0 || isnan( x ) ) { + return minmax(); } - if (isnan(x)) { - return hasValues ? accumulator() : null; - } - hasValues = true; - return accumulator(x); - }; + return minmax( x ); + } } + // EXPORTS // + module.exports = incrnanminmaxabs; diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/package.json b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/package.json index e255d07b0ac9..4095b8597daf 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/package.json @@ -1,74 +1,72 @@ { - "name": "@stdlib/stats/incr/nanminmaxabs", - "version": "0.0.0", - "description": "Compute minimum and maximum absolute values incrementally, ignoring NaNs.", - "license": "Apache-2.0", - "author": { + "name": "@stdlib/stats/incr/nanminmaxabs", + "version": "0.0.0", + "description": "Compute minimum and maximum absolute values 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", - "maximum", - "max", - "minimum", - "min", - "absolute", - "value", - "abs", - "math.abs", - "range", - "extent", - "extrema", - "incremental", - "accumulator", - "nan", - "ignore-nans" - ] - } + } + ], + "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", + "minimum", + "min", + "absolute", + "value", + "abs", + "math.abs", + "range", + "extent", + "extrema", + "incremental", + "accumulator" + ] +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/test/test.js index 40c5f86e28d9..71b0e19c1bc7 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/test/test.js @@ -1,259 +1,262 @@ /** - * @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"; +* @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 tape = require("tape"); -var isPositiveZero = require("@stdlib/math/base/assert/is-positive-zero"); -var isnan = require("@stdlib/math/base/assert/is-nan"); -var incrnanminmaxabs = require("./../lib"); +var tape = require( 'tape' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var incrnanminmaxabs = require( './../lib' ); + // TESTS // -tape("main export is a function", function test(t) { - t.ok(true, __filename); - t.strictEqual( - typeof incrnanminmaxabs, - "function", - "main export is a function" - ); +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrnanminmaxabs, 'function', 'main export is a function' ); t.end(); }); -tape( - "the function throws an error if not provided an array-like object for an output argument", - function test(t) { - var values; - var i; - - values = [ - "5", - -5.0, - true, - false, - null, - void 0, - NaN, - {}, - function noop() {}, - ]; - - for (i = 0; i < values.length; i++) { - t.throws( - badValue(values[i]), - TypeError, - "throws an error when provided " + values[i] - ); - } - t.end(); - - function badValue(value) { - return function badValue() { - incrnanminmaxabs(value); - }; - } +tape( 'the function throws an error if not provided an array-like object for an output argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5.0, + true, + false, + null, + void 0, + NaN, + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); } -); + t.end(); -tape("the function returns an accumulator function", function test(t) { - t.equal(typeof incrnanminmaxabs(), "function", "returns a function"); + function badValue( value ) { + return function badValue() { + incrnanminmaxabs( value ); + }; + } +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.strictEqual( typeof incrnanminmaxabs(), 'function', 'returns expected value' ); t.end(); }); -tape("the function returns an accumulator function (output)", function test(t) { - t.equal( - typeof incrnanminmaxabs([0.0, 0.0]), - "function", - "returns a function" - ); +tape( 'the function returns an accumulator function (output)', function test( t ) { + t.strictEqual( typeof incrnanminmaxabs( [ 0.0, 0.0 ] ), 'function', 'returns expected value' ); t.end(); }); -tape( - "the accumulator function computes a minimum and maximum absolute value incrementally", - function test(t) { - var expected; - var actual; - var data; - var acc; - var N; - var i; - - data = [ - 2.0, -3.0, -2.0, 4.0, -3.0, -4.0, -2.0, 2.0, -2.0, 1.0, -0.0, 4.0, -1.0, - ]; - N = data.length; - - acc = incrnanminmaxabs(); - - actual = []; - for (i = 0; i < N; i++) { - actual.push(acc(data[i]).slice()); - } - expected = [ - [2.0, 2.0], - [2.0, 3.0], - [2.0, 3.0], - [2.0, 4.0], - [2.0, 4.0], - [2.0, 4.0], - [2.0, 4.0], - [2.0, 4.0], - [2.0, 4.0], - [1.0, 4.0], - [0.0, 4.0], - [0.0, 4.0], - [0.0, 4.0], - ]; - - t.deepEqual(actual, expected, "returns expected values"); - t.end(); - } -); - -tape( - "the accumulator function computes a minimum and maximum absolute value incrementally (output)", - function test(t) { - var expected; - var actual; - var data; - var acc; - var out; - var N; - var i; - - data = [ - 2.0, -3.0, -2.0, 4.0, -3.0, -4.0, -2.0, 2.0, -2.0, 1.0, -0.0, 4.0, -1.0, - ]; - N = data.length; - - out = [0.0, 0.0]; - acc = incrnanminmaxabs(out); - - actual = []; - for (i = 0; i < N; i++) { - actual.push(acc(data[i])); - t.equal(actual[i], out, "returns output array"); - actual[i] = actual[i].slice(); - } - expected = [ - [2.0, 2.0], - [2.0, 3.0], - [2.0, 3.0], - [2.0, 4.0], - [2.0, 4.0], - [2.0, 4.0], - [2.0, 4.0], - [2.0, 4.0], - [2.0, 4.0], - [1.0, 4.0], - [0.0, 4.0], - [0.0, 4.0], - [0.0, 4.0], - ]; - - t.deepEqual(actual, expected, "returns expected values"); - t.end(); +tape( 'the accumulator function computes a minimum and maximum absolute value incrementally, ignoring `NaN` values', function test( t ) { + var expected; + var actual; + var data; + var acc; + var N; + var i; + + data = [ + 2.0, + NaN, + -3.0, + -2.0, + 4.0, + -3.0, + NaN, + -4.0, + -2.0, + 2.0, + -2.0, + 1.0, + -0.0, + 4.0, + -1.0 + ]; + N = data.length; + + acc = incrnanminmaxabs(); + + actual = []; + for ( i = 0; i < N; i++ ) { + actual.push( ( acc( data[ i ] ) ).slice() ); } -); - -tape( - "if not provided an input value, the accumulator function returns the current minimum and maximum absolute values", - function test(t) { - var data; - var acc; - var i; - - data = [2.0, -3.0, -5.0, 4.0]; - acc = incrnanminmaxabs(); - for (i = 0; i < data.length; i++) { - acc(data[i]); - } - t.deepEqual(acc(), [2.0, 5.0], "returns expected value"); - t.end(); + expected = [ + [ 2.0, 2.0 ], + [ 2.0, 2.0 ], + [ 2.0, 3.0 ], + [ 2.0, 3.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 1.0, 4.0 ], + [ 0.0, 4.0 ], + [ 0.0, 4.0 ], + [ 0.0, 4.0 ] + ]; + + t.deepEqual( actual, expected, 'returns expected values' ); + t.end(); +}); + +tape( 'the accumulator function computes a minimum and maximum absolute value incrementally, ignoring `NaN` values (output)', function test( t ) { + var expected; + var actual; + var data; + var acc; + var out; + var N; + var i; + + data = [ + 2.0, + NaN, + -3.0, + -2.0, + 4.0, + -3.0, + -4.0, + -2.0, + 2.0, + -2.0, + 1.0, + -0.0, + 4.0, + -1.0 + ]; + N = data.length; + + out = [ 0.0, 0.0 ]; + acc = incrnanminmaxabs( out ); + + actual = []; + for ( i = 0; i < N; i++ ) { + actual.push( acc( data[ i ] ) ); + t.strictEqual( actual[ i ], out, 'returns output array' ); + actual[ i ] = actual[ i ].slice(); } -); - -tape( - "if data has yet to be provided, the accumulator function returns `null`", - function test(t) { - var acc = incrnanminmaxabs(); - t.equal(acc(), null, "returns null"); - t.end(); + expected = [ + [ 2.0, 2.0 ], + [ 2.0, 2.0 ], + [ 2.0, 3.0 ], + [ 2.0, 3.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 1.0, 4.0 ], + [ 0.0, 4.0 ], + [ 0.0, 4.0 ], + [ 0.0, 4.0 ] + ]; + + t.deepEqual( actual, expected, 'returns expected values' ); + t.end(); +}); + +tape( 'if not provided an input value, the accumulator function returns the current minimum and maximum absolute values', function test( t ) { + var data; + var acc; + var i; + + data = [ 2.0, NaN, -3.0, -5.0, 4.0 ]; + acc = incrnanminmaxabs(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); } -); + t.deepEqual( acc(), [ 2.0, 5.0 ], 'returns expected value' ); + t.end(); +}); -tape( - "the accumulator function correctly handles signed zeros", - function test(t) { - var acc; - var v; +tape( 'if data has yet to be provided, the accumulator function returns `null`', function test( t ) { + var acc = incrnanminmaxabs(); + t.strictEqual( acc(), null, 'returns expected value' ); + t.end(); +}); - acc = incrnanminmaxabs(); +tape( 'if `NaN` is provided before any other values, the accumulator function returns `null`', function test( t ) { + var acc = incrnanminmaxabs(); + t.strictEqual( acc( NaN ), null, 'returns expected value' ); + t.end(); +}); - v = acc(0.0); - t.equal(isPositiveZero(v[0]), true, "returns expected value"); - t.equal(isPositiveZero(v[1]), true, "returns expected value"); +tape( 'the accumulator function correctly handles signed zeros', function test( t ) { + var acc; + var v; - v = acc(-0.0); - t.equal(isPositiveZero(v[0]), true, "returns expected value"); - t.equal(isPositiveZero(v[1]), true, "returns expected value"); + acc = incrnanminmaxabs(); - v = acc(0.0); - t.equal(isPositiveZero(v[0]), true, "returns expected value"); - t.equal(isPositiveZero(v[1]), true, "returns expected value"); + v = acc( 0.0 ); + t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns expected value' ); - acc = incrnanminmaxabs(); + v = acc( -0.0 ); + t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns expected value' ); - v = acc(-0.0); - t.equal(isPositiveZero(v[0]), true, "returns expected value"); - t.equal(isPositiveZero(v[1]), true, "returns expected value"); + v = acc( 0.0 ); + t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns expected value' ); - v = acc(0.0); - t.equal(isPositiveZero(v[0]), true, "returns expected value"); - t.equal(isPositiveZero(v[1]), true, "returns expected value"); + acc = incrnanminmaxabs(); - v = acc(-0.0); - t.equal(isPositiveZero(v[0]), true, "returns expected value"); - t.equal(isPositiveZero(v[1]), true, "returns expected value"); + v = acc( -0.0 ); + t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns expected value' ); - t.end(); - } -); - -tape( - "if provided `NaN`, the accumulator ignores it and continues computing min/max absolute values", - function test(t) { - var data; - var acc; - var v; - var i; - - data = [2.0, NaN, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]; - acc = incrnanminmaxabs(); // Ensure this calls your new implementation - for (i = 0; i < data.length; i++) { - acc(data[i]); - } - v = acc(); - t.equal(v[0], 1.0, "returns expected minimum absolute value"); - t.equal(v[1], 7.0, "returns expected maximum absolute value"); - t.end(); + v = acc( 0.0 ); + t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns expected value' ); + + v = acc( -0.0 ); + t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided `NaN`, the accumulator function ignores the value and continues computing minimum and maximum absolute values', function test( t ) { + var data; + var acc; + var v; + var i; + + data = [ 2.0, NaN, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, -7.0 ]; + acc = incrnanminmaxabs(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); } -); + v = acc(); + t.strictEqual( v[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( v[ 1 ], 7.0, 'returns expected value' ); + t.end(); +}); From 01f240f5507869f926f3d7d80b5f0c04b6d1042d Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 18 Jul 2026 23:40:25 -0500 Subject: [PATCH 3/3] fix: address review feedback --- .../@stdlib/stats/incr/nanminmaxabs/README.md | 6 +++--- .../stats/incr/nanminmaxabs/benchmark/benchmark.js | 2 +- .../@stdlib/stats/incr/nanminmaxabs/docs/repl.txt | 7 +++---- .../stats/incr/nanminmaxabs/docs/types/index.d.ts | 2 +- .../stats/incr/nanminmaxabs/docs/types/test.ts | 2 +- .../stats/incr/nanminmaxabs/examples/index.js | 2 +- .../@stdlib/stats/incr/nanminmaxabs/lib/index.js | 2 +- .../@stdlib/stats/incr/nanminmaxabs/lib/main.js | 13 ++++--------- .../@stdlib/stats/incr/nanminmaxabs/test/test.js | 2 +- 9 files changed, 16 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/README.md b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/README.md index a841a1206ac1..ba341c13399d 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/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. @@ -32,13 +32,13 @@ var incrnanminmaxabs = require( '@stdlib/stats/incr/nanminmaxabs' ); #### incrnanminmaxabs( \[out] ) -Returns an accumulator function which incrementally computes minimum and maximum absolute values, ignoring `NaN` values. +Returns an accumulator `function` which incrementally computes minimum and maximum absolute values, ignoring `NaN` values. ```javascript var accumulator = incrnanminmaxabs(); ``` -By default, the returned accumulator function returns the minimum and maximum absolute values as a two-element `array`. To avoid unnecessary memory allocation, the function supports providing an output (destination) object. +By default, the returned accumulator `function` returns the minimum and maximum absolute values as a two-element `array`. To avoid unnecessary memory allocation, the function supports providing an output (destination) object. ```javascript var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js index 5ef5af543ae9..4c2647bdc85c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/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/nanminmaxabs/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/repl.txt index fea5d1196e96..1905e6b93b57 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/repl.txt @@ -25,12 +25,11 @@ > var accumulator = {{alias}}(); > var mm = accumulator() null - > mm = accumulator( 2.0 ) - [ 2.0, 2.0 ] - > mm = accumulator( NaN ) - [ 2.0, 2.0 ] + > mm = accumulator( 2.0 ); > mm = accumulator( -5.0 ) [ 2.0, 5.0 ] + > mm = accumulator( NaN ) + [ 2.0, 5.0 ] > mm = accumulator( 3.0 ) [ 2.0, 5.0 ] > mm = accumulator() diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/index.d.ts index 11e4a627cd7b..ded3f492a292 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/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/nanminmaxabs/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/test.ts index 340395315818..6299455b4788 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/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/nanminmaxabs/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/examples/index.js index 7e99a466a6ef..7293c1286144 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/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/nanminmaxabs/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/index.js index 4a5bb831c2e9..1726b4ef5aa0 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/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/nanminmaxabs/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/main.js index 99261cb83669..8a0c193761c9 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/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. @@ -20,10 +20,8 @@ // MODULES // -var isArrayLike = require( '@stdlib/assert/is-array-like-object' ); var incrminmaxabs = require( '@stdlib/stats/incr/minmaxabs' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var format = require( '@stdlib/string/format' ); // MAIN // @@ -58,13 +56,10 @@ var format = require( '@stdlib/string/format' ); */ function incrnanminmaxabs( out ) { var minmax; - if ( arguments.length === 0 ) { - minmax = incrminmaxabs(); - } else { - if ( !isArrayLike( out ) ) { - throw new TypeError( format( 'invalid argument. Output argument must be an array-like object. Value: `%s`.', out ) ); - } + if ( arguments.length > 0 ) { minmax = incrminmaxabs( out ); + } else { + minmax = incrminmaxabs(); } return accumulator; diff --git a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/test/test.js index 71b0e19c1bc7..352ebd79bd52 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanminmaxabs/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.