From 8899b54403b7d480d342c4fa64a546781dc1a959 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 28 Mar 2025 15:55:32 +0530 Subject: [PATCH 1/5] feat add --- .../@stdlib/stats/incr/nanmminmax/README.md | 172 +++++++ .../incr/nanmminmax/benchmark/benchmark.js | 69 +++ .../stats/incr/nanmminmax/docs/repl.txt | 49 ++ .../incr/nanmminmax/docs/types/index.d.ts | 109 ++++ .../stats/incr/nanmminmax/docs/types/test.ts | 78 +++ .../stats/incr/nanmminmax/examples/index.js | 42 ++ .../stats/incr/nanmminmax/lib/index.js | 57 +++ .../@stdlib/stats/incr/nanmminmax/lib/main.js | 86 ++++ .../stats/incr/nanmminmax/package.json | 74 +++ .../stats/incr/nanmminmax/test/test.js | 483 ++++++++++++++++++ 10 files changed, 1219 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmminmax/README.md create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmminmax/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmminmax/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmminmax/package.json create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmminmax/test/test.js diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/README.md b/lib/node_modules/@stdlib/stats/incr/nanmminmax/README.md new file mode 100644 index 000000000000..87f1474c7c32 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/README.md @@ -0,0 +1,172 @@ + + +# incrnanmminmax + +> Compute a moving minimum and maximum incrementally ignoring `NaN` values. + +
+ +## Usage + +```javascript +var incrnanmminmax = require( '@stdlib/stats/incr/nanmminmax' ); +``` + +#### incrnanmminmax( \[out,] window ) + +Returns an accumulator `function` which incrementally computes a moving minimum and maximum, ignoring `NaN` values. The `window` parameter defines the number of values over which to compute the moving minimum and maximum. + +```javascript +var accumulator = incrnanmminmax( 3 ); +``` + +By default, the returned accumulator `function` returns the minimum and maximum 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 = incrnanmminmax( new Float64Array( 2 ), 3 ); +``` + +#### accumulator( \[x] ) + +If provided an input value `x`, the accumulator function returns updated minimum and maximum values. If not provided an input value `x`, the accumulator function returns the current minimum and maximum values. + +```javascript +var accumulator = incrnanmminmax( 3 ); + +var mm = accumulator(); +// returns null + +// Fill the window... +mm = accumulator( 2.0 ); // [2.0] +// returns [ 2.0, 2.0 ] + +mm = accumulator( 1.0 ); // [2.0, 1.0] +// returns [ 1.0, 2.0 ] + +mm = accumulator( 3.0 ); // [2.0, 1.0, 3.0] +// returns [ 1.0, 3.0 ] + +// Window begins sliding... +mm = accumulator( -7.0 ); // [1.0, 3.0, -7.0] +// returns [ -7.0, 3.0 ] + +mm = accumulator( NaN ); // [1.0, 3.0, -7.0] +// returns [ -7.0, 3.0 ] + +mm = accumulator( -5.0 ); // [3.0, -7.0, -5.0] +// returns [ -7.0, 3.0 ] + +mm = accumulator(); +// returns [ -7.0, 3.0 ] +``` + +
+ + + +
+ +## Notes + +- Input values are **not** type checked. If provided `NaN`, the accumulated minimum and maximum values are `NaN` for **at least** `W-1` future invocations. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function. +- As `W` values are needed to fill the window buffer, the first `W-1` returned minimum and maximum values are calculated from smaller sample sizes. Until the window is full, each returned minimum and maximum is calculated from all provided values. + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var incrnanmminmax = require( '@stdlib/stats/incr/nanmminmax' ); + +var accumulator; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanmminmax( 5 ); + +// For each simulated datum, update the moving minimum and maximum... +for ( i = 0; i < 100; i++ ) { + if ( randu() < 0.2 ) { + v = NaN; + } else { + v = randu() * 100.0; + } + accumulator( v ); +} +console.log( accumulator() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/benchmark/benchmark.js new file mode 100644 index 000000000000..c26cb31bd515 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/benchmark/benchmark.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var pkg = require( './../package.json' ).name; +var incrnanmminmax = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var f; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = incrnanmminmax( (i%5)+1 ); + 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 = incrnanmminmax( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = acc( randu() ); + if ( v.length !== 2 ) { + b.fail( 'should contain two elements' ); + } + } + b.toc(); + if ( v[ 0 ] !== v[ 0 ] || v[ 1 ] !== v[ 1 ] ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/repl.txt new file mode 100644 index 000000000000..e3f0e79c7618 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/repl.txt @@ -0,0 +1,49 @@ + +{{alias}}( [out,] W ) + Returns an accumulator function which incrementally computes a moving + minimum and maximum, ignoring `NaN` values. + + The `W` parameter defines the number of values over which to compute the + moving minimum and maximum. + + If provided a value, the accumulator function returns an updated moving + minimum and maximum. If not provided a value, the accumulator function + returns the current moving minimum and maximum. + + As `W` values are needed to fill the window buffer, the first `W-1` returned + minimum and maximum values are calculated from smaller sample sizes. Until + the window is full, each returned minimum and maximum is calculated from all + provided values. + + Parameters + ---------- + out: Array|TypedArray (optional) + Output array. + + W: integer + Window size. + + Returns + ------- + acc: Function + Accumulator function. + + Examples + -------- + > var accumulator = {{alias}}( 3 ); + > var mm = accumulator() + null + > mm = accumulator( 2.0 ) + [ 2.0, 2.0 ] + > mm = accumulator( -5.0 ) + [ -5.0, 2.0 ] + > mm = accumulator( NaN ) + [ -5.0, 2.0 ] + > mm = accumulator( 5.0 ) + [ -5.0, 5.0 ] + > mm = accumulator() + [ -5.0, 5.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/types/index.d.ts new file mode 100644 index 000000000000..53c7ce4548f1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/types/index.d.ts @@ -0,0 +1,109 @@ +/* +* @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 minimum and maximum values. If not provided a value, the accumulator function returns the current minimum and maximum values. +* +* @param x - input value +* @returns output array or null +*/ +type accumulator = ( x?: number ) => ArrayLike | null; + +/** +* Returns an accumulator function which incrementally computes moving minimum and maximum values ignoring `NaN` values. +* +* ## Notes +* +* - The `W` parameter defines the number of values over which to compute the moving minimum and maximum. +* - As `W` values are needed to fill the window buffer, the first `W-1` returned minimum and maximum values are calculated from smaller sample sizes. Until the window is full, each returned minimum and maximum is calculated from all provided values. +* +* @param out - output array +* @param window - window size +* @throws window size must be a positive integer +* @returns accumulator function +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var accumulator = incrnanmminmax( new Float64Array( 2 ), 3 ); +* +* var mm = accumulator(); +* // returns null +* +* mm = accumulator( 2.0 ); +* // returns [ 2.0, 2.0 ] +* +* mm = accumulator( -5.0 ); +* // returns [ -5.0, 2.0 ] +* +* mm = accumulator( NaN ); +* // returns [ -5.0, 2.0 ] +* +* mm = accumulator( 5.0 ); +* // returns [ -5.0, 5.0 ] +* +* mm = accumulator(); +* // returns [ -5.0, 5.0 ] +*/ +declare function incrnanmminmax( out: ArrayLike, window: number ): accumulator; + +/** +* Returns an accumulator function which incrementally computes moving minimum and maximum values. +* +* ## Notes +* +* - The `W` parameter defines the number of values over which to compute the moving minimum and maximum. +* - As `W` values are needed to fill the window buffer, the first `W-1` returned minimum and maximum values are calculated from smaller sample sizes. Until the window is full, each returned minimum and maximum is calculated from all provided values. +* +* @param window - window size +* @throws window size must be a positive integer +* @returns accumulator function +* +* @example +* var accumulator = incrnanmminmax( 3 ); +* +* var mm = accumulator(); +* // returns null +* +* mm = accumulator( 2.0 ); +* // returns [ 2.0, 2.0 ] +* +* mm = accumulator( -5.0 ); +* // returns [ -5.0, 2.0 ] +* +* mm = accumulator( NaN ); +* // returns [ -5.0, 2.0 ] +* +* mm = accumulator( 5.0 ); +* // returns [ -5.0, 5.0 ] +* +* mm = accumulator(); +* // returns [ -5.0, 5.0 ] +*/ +declare function incrnanmminmax( window: number ): accumulator; + + +// EXPORTS // + +export = incrnanmminmax; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/types/test.ts new file mode 100644 index 000000000000..f9daa3e59381 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/docs/types/test.ts @@ -0,0 +1,78 @@ +/* +* @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 incrnanmminmax = require( './index' ); + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnanmminmax( 3 ); // $ExpectType accumulator + const out = [ 0.0, 0.0 ]; + incrnanmminmax( out, 3 ); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided a last argument that is not a number... +{ + incrnanmminmax( '5' ); // $ExpectError + incrnanmminmax( true ); // $ExpectError + incrnanmminmax( false ); // $ExpectError + incrnanmminmax( null ); // $ExpectError + incrnanmminmax( {} ); // $ExpectError + incrnanmminmax( ( x: number ): number => x ); // $ExpectError + + const out = [ 0.0, 0.0 ]; + incrnanmminmax( out, '5' ); // $ExpectError + incrnanmminmax( out, true ); // $ExpectError + incrnanmminmax( out, false ); // $ExpectError + incrnanmminmax( out, null ); // $ExpectError + incrnanmminmax( out, {} ); // $ExpectError + incrnanmminmax( out, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an output array that is not an array-like object of numbers... +{ + incrnanmminmax( '5', 3 ); // $ExpectError + incrnanmminmax( true, 3 ); // $ExpectError + incrnanmminmax( false, 3 ); // $ExpectError + incrnanmminmax( null, 3 ); // $ExpectError + incrnanmminmax( {}, 3 ); // $ExpectError + incrnanmminmax( ( x: number ): number => x, 3 ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnanmminmax( 3 ); + + 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 = incrnanmminmax( 3 ); + + 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/nanmminmax/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/examples/index.js new file mode 100644 index 000000000000..7a662a3ff83f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/examples/index.js @@ -0,0 +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. +*/ + +'use strict'; + +var randu = require( '@stdlib/random/base/randu' ); +var incrnanmminmax = require( './../lib' ); + +var accumulator; +var mm; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanmminmax( 5 ); + +// For each simulated datum, update the moving minimum and maximum... +console.log( '\nValue\tMin\tMax\n' ); +for ( i = 0; i < 100; i++ ) { + if ( randu() < 0.2 ) { + v = NaN; + } else { + v = randu() * 100.0; + } + mm = accumulator( v ); + console.log( '%d\t%d\t%d', v.toFixed( 4 ), ( mm === null ) ? NaN : mm[ 0 ].toFixed( 4 ), ( mm === null ) ? NaN : mm[ 1 ].toFixed( 4 ) ); +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/index.js new file mode 100644 index 000000000000..ae0e6de85955 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/index.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Compute a moving minimum and maximum incrementally. +* +* @module @stdlib/stats/incr/nanmminmax +* +* @example +* var incrnanmminmax = require( '@stdlib/stats/incr/nanmminmax' ); +* +* var accumulator = incrnanmminmax( 3 ); +* +* var mm = accumulator(); +* // returns null +* +* mm = accumulator( 2.0 ); +* // returns [ 2.0, 2.0 ] +* +* mm = accumulator( -5.0 ); +* // returns [ -5.0, 2.0 ] +* +* mm = accumulator( NaN ); +* // returns [ -5.0, 2.0 ] +* +* mm = accumulator( 5.0 ); +* // returns [ -5.0, 5.0 ] +* +* mm = accumulator(); +* // returns [ -5.0, 5.0 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js new file mode 100644 index 000000000000..cc787dd61ca2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js @@ -0,0 +1,86 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var incrmminmax = require( '@stdlib/stats/incr/mminmax' ); + + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes moving minimum and maximum values, ignoring `NaN` values. +* +* @param {Collection} [out] - output array +* @param {PositiveInteger} window - window size +* @throws {TypeError} output argument must be array-like +* @throws {TypeError} window size must be a positive integer +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrmminmax( 3 ); +* +* var mm = accumulator(); +* // returns null +* +* mm = accumulator( 2.0 ); +* // returns [ 2.0, 2.0 ] +* +* mm = accumulator( -5.0 ); +* // returns [ -5.0, 2.0 ] +* +* mm = accumulator( NaN ); +* // returns [ -5.0, 2.0 ] +* +* mm = accumulator( 5.0 ); +* // returns [ -5.0, 5.0 ] +* +* mm = accumulator(); +* // returns [ -5.0, 5.0 ] +*/ +function incrmnanminmax(out, window) { + var minmax; + if (arguments.length === 1) { + minmax = incrmminmax( out ); + } else { + minmax = incrmminmax( out, window ); + } + return accumulator; + + /** + * If provided a value, the accumulator function returns updated minimum and maximum values. If not provided a value, the accumulator function returns the current minimum and maximum values. + * + * @private + * @param {number} [x] - new value + * @returns {(ArrayLikeObject|null)} min/max array or null + */ + function accumulator(x) { + if (arguments.length === 0 || isnan(x)) { + return minmax(); + } + return minmax(x); + } +} + + +// EXPORTS // + +module.exports = incrmnanminmax; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/package.json b/lib/node_modules/@stdlib/stats/incr/nanmminmax/package.json new file mode 100644 index 000000000000..21d40b9fc66b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/stats/incr/nanmminmax", + "version": "0.0.0", + "description": "Compute a moving minimum and maximum incrementally.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "mathematics", + "math", + "maximum", + "max", + "minimum", + "min", + "dispersion", + "variance", + "range", + "extent", + "extrema", + "incremental", + "accumulator", + "sliding window", + "sliding", + "window", + "moving" + ] +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/test/test.js new file mode 100644 index 000000000000..9a41d97f3f1b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/test/test.js @@ -0,0 +1,483 @@ +/** +* @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 isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var incrnanmminmax = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrnanmminmax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if not provided a positive integer for the window size', function test( t ) { + var values; + var i; + + values = [ + '5', + -5.0, + 0.0, + 3.14, + 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() { + incrnanmminmax( value ); + }; + } +}); + +tape( 'the function throws an error if not provided a positive integer for the window size (output argument)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5.0, + 0.0, + 3.14, + 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() { + incrnanmminmax( [ 0.0, 0.0 ], 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(); + + function badValue( value ) { + return function badValue() { + incrnanmminmax( value, 3 ); + }; + } +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.equal( typeof incrnanmminmax( 3 ), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the function returns an accumulator function (output)', function test( t ) { + t.equal( typeof incrnanmminmax( [ 0.0, 0.0 ], 3 ), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the accumulator function computes a moving minimum and maximum incrementally', function test( t ) { + var expected; + var actual; + var data; + var acc; + var N; + var i; + + data = [ 2.0, NaN, 3.0, 2.0, NaN, 4.0, 3.0, NaN, 4.0, 2.0, 2.0, 1.0, 0.0 ]; + N = data.length; + + acc = incrnanmminmax( 3 ); + + actual = []; + for ( i = 0; i < N; i++ ) { + actual.push( ( acc( data[ i ] ) ).slice() ); + } + expected = [ + [ 2.0, 2.0 ], + [ 2.0, 2.0 ], + [ 2.0, 3.0 ], + [ 2.0, 3.0 ], + [ 2.0, 3.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 3.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 1.0, 2.0 ], + [ 0.0, 2.0 ] + ]; + + t.deepEqual( actual, expected, 'returns expected incremental results' ); + t.end(); +}); + +tape( 'the accumulator function computes a moving minimum and maximum incrementally (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, NaN, 4.0, 3.0, 4.0, NaN, 2.0, 2.0, 1.0, 0.0 ]; + N = data.length; + + out = [ 0.0, 0.0 ]; + acc = incrnanmminmax( out, 3 ); + + 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, 2.0 ], + [ 2.0, 3.0 ], + [ 2.0, 3.0 ], + [ 2.0, 3.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 3.0, 4.0 ], + [ 3.0, 4.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 1.0, 2.0 ], + [ 0.0, 2.0 ] + ]; + + t.deepEqual( actual, expected, 'returns expected incremental results' ); + t.end(); +}); + +tape( 'if not provided an input value, the accumulator function returns the current minimum and maximum values', function test( t ) { + var data; + var acc; + var i; + + data = [ 2.0, 3.0, 5.0, 4.0 ]; + acc = incrnanmminmax( 2 ); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); + } + t.deepEqual( acc(), [ 4.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 = incrnanmminmax( 3 ); + t.equal( acc(), null, 'returns null' ); + t.end(); +}); + +tape( 'the accumulator function correctly handles signed zeros', function test( t ) { + var expected; + var data; + var sgn1; + var sgn2; + var acc; + var v; + var i; + + acc = incrnanmminmax( 3 ); + + data = [ + 0.0, // 0 => min: 0.0, max: 0.0 (0) + -0.0, // 0, -0 => min: -0.0, max: 0.0 (1) + 0.0, // 0, -0, 0 => min: -0.0, max: 0.0 (2) + 0.0, // -0, 0, 0 => min: -0.0, max: 0.0 (3) + 0.0, // 0, 0, 0 => min: 0.0, max: 0.0 (4) + -0.0, // 0, 0, -0 => min: -0.0, max: 0.0 (5) + 0.0, // 0, -0, 0 => min: -0.0, max: 0.0 (6) + 0.0, // -0, 0, 0 => min: -0.0, max: 0.0 (7) + 0.0, // 0, 0, 0 => min: 0.0, max: 0.0 (8) + -0.0, // 0, 0, -0 => min: -0.0, max: 0.0 (9) + -0.0, // 0, -0, -0 => min: -0.0, max: 0.0 (10) + -0.0, // -0, -0, -0 => min: -0.0, max: -0.0 (11) + 0.0, // -0, -0, 0 => min: -0.0, max: 0.0 (12) + + -0.0, // -0, 0, -0 => min: -0.0, max: 0.0 (13) + 0.0, // 0, -0, 0 => min: -0.0, max: 0.0 (14) + -0.0, // -0, 0, -0 => min: -0.0, max: 0.0 (15) + -0.0, // 0, -0, -0 => min: -0.0, max: 0.0 (16) + -0.0, // -0, -0, -0 => min: -0.0, max: -0.0 (17) + 0.0, // -0, -0, 0 => min: -0.0, max: 0.0 (18) + -0.0, // -0, 0, -0 => min: -0.0, max: 0.0 (19) + -0.0, // 0, -0, -0 => min: -0.0, max: 0.0 (20) + -0.0, // -0, -0, -0 => min: -0.0, max: -0.0 (21) + 0.0, // -0, -0, 0 => min: -0.0, max: 0.0 (22) + 0.0, // -0, 0, 0 => min: -0.0, max: 0.0 (23) + 0.0, // 0, 0, 0 => min: 0.0, max: 0.0 (24) + -0.0, // 0, 0, -0 => min: -0.0, max: 0.0 (25) + + // Case 1: out: -0, in: +0, cnt: 1 + 3.14, // 0, -0, 3.14 => min: -0.0, max: 3.14 + 3.14, // -0, 3.14, 3.14 => min: -0.0, max: 3.14 + 0.0, // 3.14, 3.14, 0 => min: 0.0, max: 3.14 + + // Case 2: out: +0, in: -0, cnt: 1 + 3.14, // 3.14, 0, 3.14 => min: 0.0, max: 3.14 + 3.14, // 0, 3.14, 3.14 => min: 0.0, max: 3.14 + -0.0, // 3.14, 3.14, -0 => min: -0.0, max: 3.14 + + // Case 3: out: -0, in: -0, cnt: 1 + 3.14, // 3.14, -0, 3.14 => min: -0.0, max: 3.14 + 3.14, // -0, 3.14, 3.14 => min: -0.0, max: 3.14 + -0.0, // 3.14, 3.14, -0 => min: -0.0, max: 3.14 + + // Case 4: out: -0, in: +0, cnt: 2 + 3.14, // 3.14, -0, 3.14 => min: -0.0, max: 3.14 + -0.0, // -0, 3.14, -0 => min: -0.0, max: 3.14 + 0.0, // 3.14, -0, 0 => min: -0.0, max: 3.14 + + // Case 5: out: +0, in: +0, cnt: 1 + 3.14, // -0, 0, 3.14 => min: -0.0, max: 3.14 + 3.14, // 0, 3.14, 3.14 => min: 0.0, max: 3.14 + 0.0, // 3.14, 3.14, 0 => min: 0.0, max: 3.14 + + // Case 6: out: +0, in: -0, cnt: 2 + 3.14, // 3.14, 0, 3.14 => min: 0.0, max: 3.14 + -0.0, // 0, 3.14, -0 => min: -0.0, max: 3.14 + 0.0, // 3.14, -0, 0 => min: -0.0, max: 3.14 + + // Case 7: out: +0, in: +0, cnt: 2 + 3.14, // -0, 0, 3.14 => min: -0.0, max: 3.14 + 0.0, // 0, 3.14, 0 => min: 0.0, max: 3.14 + 0.0, // 3.14, 0, 0 => min: 0.0, max: 3.14 + + // Reset: + -0.0, // 0, 0, -0 => min: -0.0, max: 0.0 + + // Case 8: out: -0, in: +0, cnt: 1 + -3.14, // 0, -0, -3.14 => min: -3.14, max: 0.0 + -3.14, // 0, -3.14, -3.14 => min: -3.14, max: 0.0 + 0.0, // -3.14, -3.14, 0 => min: -3.14, max: 0.0 + + // Case 9: out: +0, in: -0, cnt: 1 + -3.14, // -3.14, 0, 3.14 => min: -3.14, max: 0.0 + -3.14, // 0, -3.14, -3.14 => min: -3.14, max: 0.0 + -0.0, // -3.14, -3.14, -0 => min: -3.14, max: -0.0 + + // Case 10: out: -0, in: -0, cnt: 1 + -3.14, // -3.14, -0, -3.14 => min: -3.14, max: -0.0 + -3.14, // -0, -3.14, -3.14 => min: -3.14, max: -0.0 + -0.0, // -3.14, -3.14, -0 => min: -3.14, max: -0.0 + + // Case 11: out: -0, in: +0, cnt: 2 + -3.14, // -3.14, -0, -3.14 => min: -3.14, max: -0.0 + -0.0, // -0, -3.14, -0 => min: -3.14, max: -0.0 + 0.0, // -3.14, -0, 0 => min: -3.14, max: 0.0 + + // Case 12: out: +0, in: +0, cnt: 1 + -3.14, // -0, 0, -3.14 => min: -3.14, max: 0.0 + -3.14, // 0, -3.14, -3.14 => min: -3.14, max: 0.0 + 0.0, // -3.14, -3.14, 0 => min: -3.14, max: 0.0 + + // Case 13: out: +0, in: -0, cnt: 2 + -3.14, // -3.14, 0, -3.14 => min: -3.14, max: 0.0 + -0.0, // 0, -3.14, -0 => min: -3.14, max: 0.0 + 0.0, // -3.14, -0, 0 => min: -3.14, max: 0.0 + + // Case 14: out: +0, in: +0, cnt: 2 + -3.14, // -0, 0, -3.14 => min: -3.14, max: 0.0 + 0.0, // 0, -3.14, 0 => min: -3.14, max: 0.0 + 0.0, // -3.14, 0, 0 => min: -3.14, max: 0.0 + + // Reset: + 0.0, // 0, 0, 0 => min: 0.0, max: 0.0 + + // Case 15: out: +0, in: -0, cnt: 2 + -3.14, // 0, 0, -3.14 => min: -3.14, max: 0.0 + 0.0, // 0, -3.14, 0 => min: -3.14, max: 0.0 + -0.0 // -3.14, 0, -0 => min: -3.14, max: 0.0 + ]; + expected = [ + [ 0.0, 0.0, 0 ], + [ -0.0, 0.0, 1 ], + [ -0.0, 0.0, 2 ], + [ -0.0, 0.0, 3 ], + [ 0.0, 0.0, 4 ], + [ -0.0, 0.0, 5 ], + [ -0.0, 0.0, 6 ], + [ -0.0, 0.0, 7 ], + [ 0.0, 0.0, 8 ], + [ -0.0, 0.0, 9 ], + [ -0.0, 0.0, 10 ], + [ -0.0, -0.0, 11 ], + [ -0.0, 0.0, 12 ], + + [ -0.0, 0.0, 13 ], + [ -0.0, 0.0, 14 ], + [ -0.0, 0.0, 15 ], + [ -0.0, 0.0, 16 ], + [ -0.0, -0.0, 17 ], + [ -0.0, 0.0, 18 ], + [ -0.0, 0.0, 19 ], + [ -0.0, 0.0, 20 ], + [ -0.0, -0.0, 21 ], + [ -0.0, 0.0, 22 ], + [ -0.0, 0.0, 23 ], + [ 0.0, 0.0, 24 ], + [ -0.0, 0.0, 25 ], + + // Case 1: + [ -0.0, 3.14, 26 ], + [ -0.0, 3.14, 27 ], + [ 0.0, 3.14, 28 ], + + // Case 2: + [ 0.0, 3.14, 29 ], + [ 0.0, 3.14, 30 ], + [ -0.0, 3.14, 31 ], + + // Case 3: + [ -0.0, 3.14, 32 ], + [ -0.0, 3.14, 33 ], + [ -0.0, 3.14, 34 ], + + // Case 4: + [ -0.0, 3.14, 35 ], + [ -0.0, 3.14, 36 ], + [ -0.0, 3.14, 37 ], + + // Case 5: + [ -0.0, 3.14, 38 ], + [ 0.0, 3.14, 39 ], + [ 0.0, 3.14, 40 ], + + // Case 6: + [ 0.0, 3.14, 41 ], + [ -0.0, 3.14, 42 ], + [ -0.0, 3.14, 43 ], + + // Case 7: + [ -0.0, 3.14, 44 ], + [ 0.0, 3.14, 45 ], + [ 0.0, 3.14, 46 ], + + // Reset: + [ -0.0, 0.0, 47 ], + + // Case 8: + [ -3.14, 0.0, 48 ], + [ -3.14, -0.0, 49 ], + [ -3.14, 0.0, 50 ], + + // Case 9: + [ -3.14, 0.0, 51 ], + [ -3.14, 0.0, 52 ], + [ -3.14, -0.0, 53 ], + + // Case 10: + [ -3.14, -0.0, 54 ], + [ -3.14, -0.0, 55 ], + [ -3.14, -0.0, 56 ], + + // Case 11: + [ -3.14, -0.0, 57 ], + [ -3.14, -0.0, 58 ], + [ -3.14, 0.0, 59 ], + + // Case 12: + [ -3.14, 0.0, 60 ], + [ -3.14, 0.0, 61 ], + [ -3.14, 0.0, 62 ], + + // Case 13: + [ -3.14, 0.0, 63 ], + [ -3.14, 0.0, 64 ], + [ -3.14, 0.0, 65 ], + + // Case 14: + [ -3.14, 0.0, 66 ], + [ -3.14, 0.0, 67 ], + [ -3.14, 0.0, 68 ], + + // Reset: + [ 0.0, 0.0, 69 ], + + // Case 15: + [ -3.14, 0.0, 70 ], + [ -3.14, 0.0, 71 ], + [ -3.14, 0.0, 72 ] + ]; + for ( i = 0; i < data.length; i++ ) { + v = acc( data[ i ] ); + if ( expected[ i ][ 0 ] === 0.0 ) { + sgn1 = isNegativeZero( v[ 0 ] ); + sgn2 = isNegativeZero( expected[ i ][ 0 ] ); + t.equal( sgn1, sgn2, 'returns expected signed zero minimum for window '+i+'. v: '+( ( isNegativeZero( data[ i ] ) ) ? '-' : '+' )+data[ i ]+'. actual: '+( ( sgn1 ) ? '-' : '+' )+v[ 0 ]+'. expected: '+( ( sgn2 ) ? '-' : '+' )+expected[ i ][ 0 ]+'.' ); + } else { + t.equal( v[ 0 ], expected[ i ][ 0 ], 'returns expected minimum for window '+i+'. v: '+data[ i ]+'. actual: '+v[ 0 ]+'. expected: '+expected[ i ][ 0 ]+'.' ); + } + if ( expected[ i ][ 1 ] === 0.0 ) { + sgn1 = isNegativeZero( v[ 1 ] ); + sgn2 = isNegativeZero( expected[ i ][ 1 ] ); + t.equal( sgn1, sgn2, 'returns expected signed zero maximum for window '+i+'. v: '+( ( isNegativeZero( data[ i ] ) ) ? '-' : '+' )+data[ i ]+'. actual: '+( ( sgn1 ) ? '-' : '+' )+v[ 1 ]+'. expected: '+( ( sgn2 ) ? '-' : '+' )+expected[ i ][ 1 ]+'.' ); + } else { + t.equal( v[ 1 ], expected[ i ][ 1 ], 'returns expected maximum for window '+i+'. v: '+data[ i ]+'. actual: '+v[ 1 ]+'. expected: '+expected[ i ][ 1 ]+'.' ); + } + } + t.end(); +}); From 14bb7908a6c5103d3b4e7b993430dd2de4331b93 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 28 Mar 2025 16:06:16 +0530 Subject: [PATCH 2/5] fix lint errors --- lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/index.js index ae0e6de85955..ce1f4e49f740 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js index cc787dd61ca2..52748efaa8b5 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js @@ -36,7 +36,7 @@ var incrmminmax = require( '@stdlib/stats/incr/mminmax' ); * @returns {Function} accumulator function * * @example -* var accumulator = incrmminmax( 3 ); +* var accumulator = incrnanmminmax( 3 ); * * var mm = accumulator(); * // returns null From 91b610bb48935e3a3e1db0857a18d0ee5ffd9ad7 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 28 Mar 2025 16:19:36 +0530 Subject: [PATCH 3/5] fix lint error --- lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js index 52748efaa8b5..61a393b59df1 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js @@ -56,7 +56,7 @@ var incrmminmax = require( '@stdlib/stats/incr/mminmax' ); * mm = accumulator(); * // returns [ -5.0, 5.0 ] */ -function incrmnanminmax(out, window) { +function incrnanmminmax(out, window) { var minmax; if (arguments.length === 1) { minmax = incrmminmax( out ); @@ -83,4 +83,4 @@ function incrmnanminmax(out, window) { // EXPORTS // -module.exports = incrmnanminmax; +module.exports = incrnanmminmax; From f66733b6889b2980e8eb8ca6eb9f2274ee71c130 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Fri, 28 Mar 2025 16:39:52 +0530 Subject: [PATCH 4/5] update main.js --- .../@stdlib/stats/incr/nanmminmax/lib/main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js index 61a393b59df1..68392e573cfe 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js @@ -57,11 +57,11 @@ var incrmminmax = require( '@stdlib/stats/incr/mminmax' ); * // returns [ -5.0, 5.0 ] */ function incrnanmminmax(out, window) { - var minmax; + var mminmax; if (arguments.length === 1) { - minmax = incrmminmax( out ); + mminmax = incrmminmax( out ); } else { - minmax = incrmminmax( out, window ); + mminmax = incrmminmax( out, window ); } return accumulator; @@ -74,9 +74,9 @@ function incrnanmminmax(out, window) { */ function accumulator(x) { if (arguments.length === 0 || isnan(x)) { - return minmax(); + return mminmax(); } - return minmax(x); + return mminmax(x); } } From f76ae5686503bc13d46089b37f05d8c4bc24735f Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Sat, 29 Mar 2025 11:49:36 +0530 Subject: [PATCH 5/5] chore: clean-up --- .../@stdlib/stats/incr/nanmminmax/README.md | 29 +------------------ .../incr/nanmminmax/benchmark/benchmark.js | 2 +- .../@stdlib/stats/incr/nanmminmax/lib/main.js | 10 +++---- .../stats/incr/nanmminmax/package.json | 2 +- .../stats/incr/nanmminmax/test/test.js | 2 +- 5 files changed, 9 insertions(+), 36 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/README.md b/lib/node_modules/@stdlib/stats/incr/nanmminmax/README.md index 87f1474c7c32..70f9f1da1b44 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmminmax/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/README.md @@ -20,7 +20,7 @@ limitations under the License. # incrnanmminmax -> Compute a moving minimum and maximum incrementally ignoring `NaN` values. +> Compute a moving minimum and maximum incrementally, ignoring `NaN` values.
@@ -132,17 +132,6 @@ console.log( accumulator() ); @@ -151,22 +140,6 @@ console.log( accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/benchmark/benchmark.js index c26cb31bd515..77c772dceb1b 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmminmax/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/benchmark/benchmark.js @@ -33,7 +33,7 @@ bench( pkg, function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - f = incrnanmminmax( (i%5)+1 ); + f = incrnanmminmax( ( i%5 ) + 1 ); if ( typeof f !== 'function' ) { b.fail( 'should return a function' ); } diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js index 68392e573cfe..58ed1419d828 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/lib/main.js @@ -56,9 +56,9 @@ var incrmminmax = require( '@stdlib/stats/incr/mminmax' ); * mm = accumulator(); * // returns [ -5.0, 5.0 ] */ -function incrnanmminmax(out, window) { +function incrnanmminmax( out, window ) { var mminmax; - if (arguments.length === 1) { + if ( arguments.length === 1 ) { mminmax = incrmminmax( out ); } else { mminmax = incrmminmax( out, window ); @@ -72,11 +72,11 @@ function incrnanmminmax(out, window) { * @param {number} [x] - new value * @returns {(ArrayLikeObject|null)} min/max array or null */ - function accumulator(x) { - if (arguments.length === 0 || isnan(x)) { + function accumulator( x ) { + if (arguments.length === 0 || isnan( x )) { return mminmax(); } - return mminmax(x); + return mminmax( x ); } } diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/package.json b/lib/node_modules/@stdlib/stats/incr/nanmminmax/package.json index 21d40b9fc66b..f1603c0f5d7e 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmminmax/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/stats/incr/nanmminmax", "version": "0.0.0", - "description": "Compute a moving minimum and maximum incrementally.", + "description": "Compute a moving minimum and maximum incrementally, ignoring `NaN` values.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/stats/incr/nanmminmax/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmminmax/test/test.js index 9a41d97f3f1b..f4362a10e715 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmminmax/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmminmax/test/test.js @@ -53,7 +53,7 @@ tape( 'the function throws an error if not provided a positive integer for the w ]; for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided '+values[ i ] ); } t.end();