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(); + } +);