From d9213cfc32d64b4a44bf43e8a0e930883f9a16d7 Mon Sep 17 00:00:00 2001 From: Hemang Chodhary Date: Sun, 23 Mar 2025 02:18:58 +0530 Subject: [PATCH 1/7] Added nanmrange --- .../@stdlib/stats/incr/nanmrange/README.md | 165 +++++++ .../incr/nanmrange/benchmark/benchmark.js | 69 +++ .../stats/incr/nanmrange/docs/repl.txt | 44 ++ .../incr/nanmrange/docs/types/index.d.ts | 78 ++++ .../stats/incr/nanmrange/docs/types/test.ts | 66 +++ .../stats/incr/nanmrange/examples/index.js | 38 ++ .../@stdlib/stats/incr/nanmrange/lib/index.js | 60 +++ .../@stdlib/stats/incr/nanmrange/lib/main.js | 80 ++++ .../@stdlib/stats/incr/nanmrange/package.json | 74 ++++ .../@stdlib/stats/incr/nanmrange/test/test.js | 419 ++++++++++++++++++ 10 files changed, 1093 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmrange/README.md create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmrange/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmrange/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmrange/package.json create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/README.md b/lib/node_modules/@stdlib/stats/incr/nanmrange/README.md new file mode 100644 index 000000000000..7e2add0aab5f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/README.md @@ -0,0 +1,165 @@ + + +# incrnanmrange + +> Compute a moving [range][range] incrementally, ignoring `NaN` values. + +
+ +The [**range**][range] is defined as the difference between the maximum and minimum values. + +
+ + + +
+ +## Usage + +```javascript +var incrnanmrange = require( '@stdlib/stats/incr/nanmrange' ); +``` + +#### incrnanmrange( window ) + +Returns an accumulator `function` which incrementally computes a moving [range][range], ignoring `NaN` values. The `window` parameter defines the number of values over which to compute the moving [range][range]. + +```javascript +var accumulator = incrnanmrange( 3 ); +``` + +#### accumulator( \[x] ) + +If provided an input value `x`, the accumulator function returns an updated [range][range]. If not provided an input value `x`, the accumulator function returns the current [range][range]. + +```javascript +var accumulator = incrnanmrange( 3 ); + +var r = accumulator(); +// returns null + +// Fill the window... +r = accumulator( 2.0 ); // [2.0] +// returns 0.0 + +r = accumulator( 1.0 ); // [2.0, 1.0] +// returns 1.0 + +r = accumulator( NaN ); // [2.0, 1.0, NaN] +// returns 1.0 + +r = accumulator( 3.0 ); // [1.0, NaN, 3.0] +// returns 2.0 + +// Window begins sliding... +r = accumulator( -7.0 ); // [NaN, 3.0, -7.0] +// returns 10.0 + +r = accumulator( -5.0 ); // [3.0, -7.0, -5.0] +// returns 10.0 + +r = accumulator(); +// returns 10.0 +``` + +
+ + + +
+ +## Notes + +- Input values are **not** type checked. If provided `NaN`, the value is ignored. 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 values are calculated from smaller sample sizes. Until the window is full, each returned value is calculated from all provided values. + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var incrnanmrange = require( '@stdlib/stats/incr/nanmrange' ); + +var accumulator; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanmrange( 5 ); + +// For each simulated datum, update the moving range... +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/nanmrange/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/benchmark/benchmark.js new file mode 100644 index 000000000000..7b83a28b2dc6 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/benchmark/benchmark.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var pkg = require( './../package.json' ).name; +var incrnanmrange = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var f; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = incrnanmrange( (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 = incrnanmrange( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = acc( randu() ); + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/repl.txt new file mode 100644 index 000000000000..9d634bf5eeef --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/repl.txt @@ -0,0 +1,44 @@ + +{{alias}}( W ) + Returns an accumulator function which incrementally computes a moving range. + + The `W` parameter defines the number of values over which to compute the + moving range. + + If provided a value, the accumulator function returns an updated moving + range. If not provided a value, the accumulator function returns the current + moving range. + + As `W` values are needed to fill the window buffer, the first `W-1` returned + values are calculated from smaller sample sizes. Until the window is full, + each returned value is calculated from all provided values. + + Parameters + ---------- + W: integer + Window size. + + Returns + ------- + acc: Function + Accumulator function. + + Examples + -------- + > var accumulator = {{alias}}( 3 ); + > var r = accumulator() + null + > r = accumulator( 2.0 ) + 0.0 + > r = accumulator( -5.0 ) + 7.0 + > r = accumulator( NaN ) + 7.0 + > r = accumulator( 5.0 ) + 10.0 + > r = accumulator() + 10.0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/index.d.ts new file mode 100644 index 000000000000..831b323d2ca1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/index.d.ts @@ -0,0 +1,78 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +/** +* If provided a value, returns an updated range; otherwise, returns the current range. +* +* ## Notes +* +* - If provided `NaN`, the `NaN` value is ignored. +* - If the number of non-NaN values in the window is less than two, the function returns `null`. +* +* @param x - value +* @returns range +*/ +type accumulator = ( x?: number ) => number | null; + +/** +* Returns an accumulator function which incrementally computes a moving range, ignoring `NaN` values. +* +* ## Notes +* +* - The `W` parameter defines the number of values over which to compute the moving range. +* - As `W` values are needed to fill the window buffer, the first `W-1` returned values are calculated from smaller sample sizes. Until the window is full, each returned value is calculated from all provided values. +* - `NaN` values are ignored. +* +* @param W - window size +* @throws must provide a positive integer +* @returns accumulator function +* +* @example +* var accumulator = incrnanmrange( 3 ); +* +* var r = accumulator(); +* // returns null +* +* r = accumulator( 2.0 ); +* // returns 0.0 +* +* r = accumulator( -5.0 ); +* // returns 7.0 +* +* r = accumulator( NaN ); +* // returns 7.0 +* +* r = accumulator( 3.0 ); +* // returns 8.0 +* +* r = accumulator( 5.0 ); +* // returns 10.0 +* +* r = accumulator(); +* // returns 10.0 +*/ +declare function incrnanmrange( W: number ): accumulator; + + +// EXPORTS // + +export = incrnanmrange; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/test.ts new file mode 100644 index 000000000000..9b3008661368 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/test.ts @@ -0,0 +1,66 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 incrnanmrange = require( './index' ); + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnanmrange( 3 ); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided an argument which is not a number... +{ + incrnanmrange( '5' ); // $ExpectError + incrnanmrange( true ); // $ExpectError + incrnanmrange( false ); // $ExpectError + incrnanmrange( null ); // $ExpectError + incrnanmrange( undefined ); // $ExpectError + incrnanmrange( [] ); // $ExpectError + incrnanmrange( {} ); // $ExpectError + incrnanmrange( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid number of arguments... +{ + incrnanmrange(); // $ExpectError + incrnanmrange( 2, 3 ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnanmrange( 3 ); + + acc(); // $ExpectType number | null + acc( 3.14 ); // $ExpectType number | null +} + +// The compiler throws an error if the returned accumulator function is provided invalid arguments... +{ + const acc = incrnanmrange( 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/nanmrange/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js new file mode 100644 index 000000000000..c117fd43a89d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js @@ -0,0 +1,38 @@ +/** +* @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'; + +var randu = require( '@stdlib/random/base/randu' ); +var incrnanmrange = require( './../lib' ); + +var accumulator; +var r; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanmrange( 5 ); + +// For each simulated datum, update the moving range... +console.log( '\nValue\tRange\n' ); +for ( i = 0; i < 100; i++ ) { + v = randu() > 0.2 ? NaN : randu() * 100.0; + r = accumulator( v ); + console.log( '%d\t%d', v.toFixed( 4 ),(r === null) ? null : r.toFixed( 4 ) ); +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js new file mode 100644 index 000000000000..88e76a336c84 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js @@ -0,0 +1,60 @@ +/** +* @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 range incrementally, ignoring NaN values. +* +* @module @stdlib/stats/incr/nanmrange +* +* @example +* var incrnanmrange = require( '@stdlib/stats/incr/nanmrange' ); +* +* var accumulator = incrnanmrange( 3 ); +* +* var r = accumulator(); +* // returns null +* +* r = accumulator( 2.0 ); +* // returns 0.0 +* +* r = accumulator( -5.0 ); +* // returns 7.0 +* +* r = accumulator( NaN ); +* // returns 7.0 +* +* r = accumulator( 3.0 ); +* // returns 8.0 +* +* r = accumulator( 5.0 ); +* // returns 10.0 +* +* r = accumulator(); +* // returns 10.0 +*/ + +// MODULES // + +var main = require( '@stdlib/stats/incr/nanmrange/lib/main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js new file mode 100644 index 000000000000..39ebc901c393 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js @@ -0,0 +1,80 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var mrange = require( '@stdlib/stats/incr/mrange' ); + + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes a moving range, ignoring `NaN` values. +* +* @param {PositiveInteger} W - window size +* @throws {TypeError} must provide a positive integer +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrnanmrange( 3 ); +* +* var r = accumulator(); +* // returns null +* +* r = accumulator( 2.0 ); +* // returns 0.0 +* +* r = accumulator( -5.0 ); +* // returns 7.0 +* +* r = accumulator( NaN ); +* // returns 7.0 +* +* r = accumulator( 3.0 ); +* // returns 8.0 +* +* r = accumulator( 5.0 ); +* // returns 10.0 +* +* r = accumulator(); +* // returns 10.0 +*/ +function incrnanmrange( W ) { + var acc = mrange( W ); + return accumulator; + + /** + * If provided a value, the accumulator function returns an updated range. If not provided a value, the accumulator function returns the current range. + * + * @private + * @param {number} [x] - new value + * @returns {(number|null)} range or null + */ + function accumulator( x ) { + if ( arguments.length === 0 || isnan( x ) ) { + return acc(); + } + return acc( x ); + } +} + +// EXPORTS // + +module.exports = incrnanmrange; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/package.json b/lib/node_modules/@stdlib/stats/incr/nanmrange/package.json new file mode 100644 index 000000000000..9ab86db1cc3e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/stats/incr/nanmrange", + "version": "0.0.0", + "description": "Compute a moving range 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", + "range", + "dispersion", + "variance", + "domain", + "extent", + "incremental", + "accumulator", + "sliding window", + "sliding", + "window", + "moving" + ] +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js new file mode 100644 index 000000000000..d8aceb2daf32 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js @@ -0,0 +1,419 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var incrnanmrange = require( '@stdlib/stats/incr/nanmrange/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrnanmrange, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if not provided a positive integer', 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() { + incrnanmrange( value ); + }; + } +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.equal( typeof incrnanmrange( 3 ), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the accumulator function computes a moving range 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 = incrnanmrange( 3 ); + + actual = []; + for ( i = 0; i < N; i++ ) { + actual.push( acc( data[ i ] ) ); + } + expected = [ + 0.0, + 1.0, + 1.0, + 2.0, + 2.0, + 1.0, + 2.0, + 2.0, + 0.0, + 1.0, + 2.0, + 4.0, + 5.0 + ]; + + t.deepEqual( actual, expected, 'returns expected incremental results' ); + t.end(); +}); + +tape( 'if not provided an input value, the accumulator function returns the current range', function test( t ) { + var data; + var acc; + var i; + + data = [ 2.0, 3.0, 5.0, 4.0 ]; + acc = incrnanmrange( 2 ); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); + } + t.equal( acc(), 1.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if data has yet to be provided, the accumulator function returns `null`', function test( t ) { + var acc = incrnanmrange( 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 acc; + var v; + var i; + + acc = incrnanmrange( 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.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + + // Case 1: + 3.14, + 3.14, + 3.14, + + // Case 2: + 3.14, + 3.14, + 3.14, + + // Case 3: + 3.14, + 3.14, + 3.14, + + // Case 4: + 3.14, + 3.14, + 3.14, + + // Case 5: + 3.14, + 3.14, + 3.14, + + // Case 6: + 3.14, + 3.14, + 3.14, + + // Case 7: + 3.14, + 3.14, + 3.14, + + // Reset: + 0.0, + + // Case 8: + 3.14, + 3.14, + 3.14, + + // Case 9: + 3.14, + 3.14, + 3.14, + + // Case 10: + 3.14, + 3.14, + 3.14, + + // Case 11: + 3.14, + 3.14, + 3.14, + + // Case 12: + 3.14, + 3.14, + 3.14, + + // Case 13: + 3.14, + 3.14, + 3.14, + + // Case 14: + 3.14, + 3.14, + 3.14, + + // Reset: + 0.0, + + // Case 15: + 3.14, + 3.14, + 3.14 + ]; + for ( i = 0; i < data.length; i++ ) { + v = acc( data[ i ] ); + if ( expected[ i ] === 0.0 ) { + t.equal( isNegativeZero( v ), isNegativeZero( expected[ i ] ), 'returns expected value for window '+i ); + } else { + t.equal( v, expected[ i ], 'returns expected value for window '+i ); + } + } + t.end(); +}); + + +tape( 'if provided NaN, the accumulator function ignores it and returns the previous result', function test( t ) { + var expected; + var data; + var acc; + var v; + var i; + + acc = incrnanmrange( 3 ); + + data = [ + 3.14, // [3.14] -> range: 0.0 (single value) + NaN, // [3.14] -> range: 0.0 (NaN ignored) + 5.0, // [3.14, 5.0] -> range: 1.86 + 7.0, // [3.14, 5.0, 7.0] -> range: 3.86 + NaN, // [3.14, 5.0, 7.0] -> range: 3.86 (NaN ignored) + NaN, // [3.14, 5.0, 7.0] -> range: 3.86 (NaN ignored) + 2.0, // [5.0, 7.0, 2.0] -> range: 5.0 + NaN, // [5.0, 7.0, 2.0] -> range: 5.0 (NaN ignored) + 1.0, // [7.0, 2.0, 1.0] -> range: 6.0 + 10.0 // [2.0, 1.0, 10.0] -> range: 9.0 + ]; + expected = [ + 0.0, // single value has range 0 + 0.0, // NaN ignored, previous value returned + 1.86, // range between 3.14 and 5.0 + 3.86, // range between 3.14 and 7.0 + 3.86, // NaN ignored, previous value returned + 3.86, // NaN ignored, previous value returned + 5.0, // range between 2.0 and 7.0 + 5.0, // NaN ignored, previous value returned + 6.0, // range between 1.0 and 7.0 + 9.0 // range between 1.0 and 10.0 + ]; + + for ( i = 0; i < data.length; i++ ) { + v = acc( data[ i ] ); + if ( isnan( expected[ i ] ) ) { + t.equal( isnan( v ), true, 'returns expected value for window '+i ); + } else if ( i === 2 ) { + t.ok( Math.abs(v - expected[i]) < 0.01, 'returns expected value for window '+i ); + } else { + t.equal( v, expected[ i ], 'returns expected value for window '+i ); + } + } + + t.equal( acc(), 9.0, 'returns current range when called without arguments' ); + + t.end(); +}); \ No newline at end of file From b729f17e588cb000c01e4eb5bbeb64d5940d586a Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Wed, 16 Apr 2025 00:13:32 +0000 Subject: [PATCH 2/7] chore: update copyright years --- lib/node_modules/@stdlib/stats/incr/nanmrange/README.md | 2 +- .../@stdlib/stats/incr/nanmrange/benchmark/benchmark.js | 2 +- .../@stdlib/stats/incr/nanmrange/docs/types/index.d.ts | 2 +- .../@stdlib/stats/incr/nanmrange/docs/types/test.ts | 2 +- lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/README.md b/lib/node_modules/@stdlib/stats/incr/nanmrange/README.md index 7e2add0aab5f..920b39c232ea 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/README.md @@ -2,7 +2,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/nanmrange/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/benchmark/benchmark.js index 7b83a28b2dc6..31fb4b52721f 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/benchmark/benchmark.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/nanmrange/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/index.d.ts index 831b323d2ca1..55c4eb8c99d1 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 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/nanmrange/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/test.ts index 9b3008661368..64c0c55ade9f 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 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/nanmrange/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js index c117fd43a89d..3c3f268106e6 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/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/nanmrange/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js index 88e76a336c84..35795c491570 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/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/nanmrange/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js index 39ebc901c393..e46888001104 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.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/nanmrange/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js index d8aceb2daf32..10430cea30b4 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From c7eb8d3d4f3f7d6771aea5e9dd1a008a8a242e22 Mon Sep 17 00:00:00 2001 From: Hemang Chodhary Date: Tue, 22 Apr 2025 12:05:18 +0530 Subject: [PATCH 3/7] Update index.js --- lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js index 35795c491570..a50e275b9719 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/index.js @@ -52,7 +52,7 @@ // MODULES // -var main = require( '@stdlib/stats/incr/nanmrange/lib/main.js' ); +var main = require( './main.js' ); // EXPORTS // From afac99befb2af2ab4749e4c36e8e4bd089a2398a Mon Sep 17 00:00:00 2001 From: Hemang Chodhary Date: Tue, 22 Apr 2025 14:40:15 +0530 Subject: [PATCH 4/7] Update main.js --- lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js index e46888001104..08f3a8240eb1 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/lib/main.js @@ -19,6 +19,7 @@ 'use strict'; // MODULES // + var isnan = require( '@stdlib/math/base/assert/is-nan' ); var mrange = require( '@stdlib/stats/incr/mrange' ); @@ -75,6 +76,7 @@ function incrnanmrange( W ) { } } + // EXPORTS // module.exports = incrnanmrange; From bfd00e6276c14ed6c9755fe6a642bfbccda9c52b Mon Sep 17 00:00:00 2001 From: Hemang Chodhary Date: Tue, 22 Apr 2025 15:02:26 +0530 Subject: [PATCH 5/7] Update test.js --- .../@stdlib/stats/incr/nanmrange/test/test.js | 95 +++++++++---------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js index 10430cea30b4..f596fe90941a 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js @@ -367,53 +367,52 @@ tape( 'the accumulator function correctly handles signed zeros', function test( t.end(); }); - tape( 'if provided NaN, the accumulator function ignores it and returns the previous result', function test( t ) { - var expected; - var data; - var acc; - var v; - var i; - - acc = incrnanmrange( 3 ); - - data = [ - 3.14, // [3.14] -> range: 0.0 (single value) - NaN, // [3.14] -> range: 0.0 (NaN ignored) - 5.0, // [3.14, 5.0] -> range: 1.86 - 7.0, // [3.14, 5.0, 7.0] -> range: 3.86 - NaN, // [3.14, 5.0, 7.0] -> range: 3.86 (NaN ignored) - NaN, // [3.14, 5.0, 7.0] -> range: 3.86 (NaN ignored) - 2.0, // [5.0, 7.0, 2.0] -> range: 5.0 - NaN, // [5.0, 7.0, 2.0] -> range: 5.0 (NaN ignored) - 1.0, // [7.0, 2.0, 1.0] -> range: 6.0 - 10.0 // [2.0, 1.0, 10.0] -> range: 9.0 - ]; - expected = [ - 0.0, // single value has range 0 - 0.0, // NaN ignored, previous value returned - 1.86, // range between 3.14 and 5.0 - 3.86, // range between 3.14 and 7.0 - 3.86, // NaN ignored, previous value returned - 3.86, // NaN ignored, previous value returned - 5.0, // range between 2.0 and 7.0 - 5.0, // NaN ignored, previous value returned - 6.0, // range between 1.0 and 7.0 - 9.0 // range between 1.0 and 10.0 - ]; - - for ( i = 0; i < data.length; i++ ) { - v = acc( data[ i ] ); - if ( isnan( expected[ i ] ) ) { - t.equal( isnan( v ), true, 'returns expected value for window '+i ); - } else if ( i === 2 ) { - t.ok( Math.abs(v - expected[i]) < 0.01, 'returns expected value for window '+i ); - } else { - t.equal( v, expected[ i ], 'returns expected value for window '+i ); - } - } - - t.equal( acc(), 9.0, 'returns current range when called without arguments' ); - - t.end(); + var expected; + var data; + var acc; + var v; + var i; + + acc = incrnanmrange( 3 ); + + data = [ + 3.14, // [3.14] -> range: 0.0 (single value) + NaN, // [3.14] -> range: 0.0 (NaN ignored) + 5.0, // [3.14, 5.0] -> range: 1.86 + 7.0, // [3.14, 5.0, 7.0] -> range: 3.86 + NaN, // [3.14, 5.0, 7.0] -> range: 3.86 (NaN ignored) + NaN, // [3.14, 5.0, 7.0] -> range: 3.86 (NaN ignored) + 2.0, // [5.0, 7.0, 2.0] -> range: 5.0 + NaN, // [5.0, 7.0, 2.0] -> range: 5.0 (NaN ignored) + 1.0, // [7.0, 2.0, 1.0] -> range: 6.0 + 10.0 // [2.0, 1.0, 10.0] -> range: 9.0 + ]; + expected = [ + 0.0, // single value has range 0 + 0.0, // NaN ignored, previous value returned + 1.86, // range between 3.14 and 5.0 + 3.86, // range between 3.14 and 7.0 + 3.86, // NaN ignored, previous value returned + 3.86, // NaN ignored, previous value returned + 5.0, // range between 2.0 and 7.0 + 5.0, // NaN ignored, previous value returned + 6.0, // range between 1.0 and 7.0 + 9.0 // range between 1.0 and 10.0 + ]; + + for ( i = 0; i < data.length; i++ ) { + v = acc( data[ i ] ); + if ( isnan( expected[ i ] ) ) { + t.equal( isnan( v ), true, 'returns expected value for window '+i ); + } else if ( i === 2 ) { + t.ok( Math.abs(v - expected[i]) < 0.01, 'returns expected value for window '+i ); + } else { + t.equal( v, expected[ i ], 'returns expected value for window '+i ); + } + } + + t.equal( acc(), 9.0, 'returns current range when called without arguments' ); + + t.end(); }); \ No newline at end of file From c7753b3df52580f73b8f2a48ce51d65581ce89a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Wed, 23 Apr 2025 07:17:20 +0000 Subject: [PATCH 6/7] fix: resolve lint errors --- .../@stdlib/stats/incr/nanmrange/README.md | 14 -------------- .../@stdlib/stats/incr/nanmrange/examples/index.js | 2 +- .../@stdlib/stats/incr/nanmrange/test/test.js | 8 ++++---- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/README.md b/lib/node_modules/@stdlib/stats/incr/nanmrange/README.md index 920b39c232ea..27c6e2977b2b 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/README.md @@ -132,14 +132,6 @@ console.log( accumulator() ); @@ -152,12 +144,6 @@ console.log( accumulator() ); -[@stdlib/stats/incr/mrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/mrange - -[@stdlib/stats/incr/nanmean]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/nanmean - -[@stdlib/stats/incr/range]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/range - diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js index 3c3f268106e6..9559d3b863ea 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js @@ -34,5 +34,5 @@ console.log( '\nValue\tRange\n' ); for ( i = 0; i < 100; i++ ) { v = randu() > 0.2 ? NaN : randu() * 100.0; r = accumulator( v ); - console.log( '%d\t%d', v.toFixed( 4 ),(r === null) ? null : r.toFixed( 4 ) ); + console.log( '%d\t%d', v.toFixed( 4 ), (r === null) ? null : r.toFixed( 4 ) ); } diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js index f596fe90941a..33fff21a66ae 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js @@ -400,7 +400,7 @@ tape( 'if provided NaN, the accumulator function ignores it and returns the prev 6.0, // range between 1.0 and 7.0 9.0 // range between 1.0 and 10.0 ]; - + for ( i = 0; i < data.length; i++ ) { v = acc( data[ i ] ); if ( isnan( expected[ i ] ) ) { @@ -411,8 +411,8 @@ tape( 'if provided NaN, the accumulator function ignores it and returns the prev t.equal( v, expected[ i ], 'returns expected value for window '+i ); } } - + t.equal( acc(), 9.0, 'returns current range when called without arguments' ); - + t.end(); -}); \ No newline at end of file +}); From fcef799f2d25a83f469d9b627ea2546169f19d81 Mon Sep 17 00:00:00 2001 From: Hemang Chodhary Date: Wed, 23 Apr 2025 18:34:12 +0530 Subject: [PATCH 7/7] [fix lint] --- .../@stdlib/stats/incr/nanmrange/examples/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js index 9559d3b863ea..dc979e1e0ddd 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/examples/index.js @@ -32,7 +32,7 @@ accumulator = incrnanmrange( 5 ); // For each simulated datum, update the moving range... console.log( '\nValue\tRange\n' ); for ( i = 0; i < 100; i++ ) { - v = randu() > 0.2 ? NaN : randu() * 100.0; + v = ( randu() > 0.2 ) ? NaN : randu() * 100.0; r = accumulator( v ); console.log( '%d\t%d', v.toFixed( 4 ), (r === null) ? null : r.toFixed( 4 ) ); } diff --git a/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js index 33fff21a66ae..74b6acc152fc 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmrange/test/test.js @@ -24,6 +24,7 @@ var tape = require( 'tape' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var incrnanmrange = require( '@stdlib/stats/incr/nanmrange/lib' ); +var abs = require( '@stdlib/math/base/special/abs' ); // TESTS // @@ -406,7 +407,7 @@ tape( 'if provided NaN, the accumulator function ignores it and returns the prev if ( isnan( expected[ i ] ) ) { t.equal( isnan( v ), true, 'returns expected value for window '+i ); } else if ( i === 2 ) { - t.ok( Math.abs(v - expected[i]) < 0.01, 'returns expected value for window '+i ); + t.ok( abs(v - expected[i]) < 0.01, 'returns expected value for window '+i ); } else { t.equal( v, expected[ i ], 'returns expected value for window '+i ); }