From 0271a9efb3da864552143f525f10befaa6aad0cc Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sat, 1 Mar 2025 23:35:12 +0530 Subject: [PATCH 01/20] added nanrange --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/stats/incr/nanrange/README.md | 153 ++++++++++++++++++ .../incr/nanrange/benchmark/benchmark.js | 69 ++++++++ .../@stdlib/stats/incr/nanrange/docs/repl.txt | 30 ++++ .../stats/incr/nanrange/docs/types/index.d.ts | 66 ++++++++ .../stats/incr/nanrange/docs/types/test.ts | 61 +++++++ .../stats/incr/nanrange/examples/index.js | 43 +++++ .../@stdlib/stats/incr/nanrange/libs/index.js | 57 +++++++ .../@stdlib/stats/incr/nanrange/libs/main.js | 91 +++++++++++ .../@stdlib/stats/incr/nanrange/package.json | 71 ++++++++ .../@stdlib/stats/incr/nanrange/test/test.js | 112 +++++++++++++ 10 files changed, 753 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/README.md create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/libs/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/package.json create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/README.md b/lib/node_modules/@stdlib/stats/incr/nanrange/README.md new file mode 100644 index 000000000000..9a1d98de0b7e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/README.md @@ -0,0 +1,153 @@ + + +# incrnanrange + +> Compute a [range][range] incrementally, ignoring `NaN` values. + +
+ +The [**range**][range] is defined as the difference between the maximum and minimum values. This implementation ignores `NaN` values. + +
+ + + +
+ +## Usage + +```javascript +var incrnanrange = require( '@stdlib/stats/incr/nanrange' ); +``` + +#### incrnanrange() + +Returns an accumulator `function` which incrementally computes a [range][range], ignoring `NaN` values. + +```javascript +var accumulator = incrnanrange(); +``` + +#### accumulator( \[x] ) + +If provided an input value `x`, the accumulator function returns an updated [range][range], ignoring `NaN` values. If not provided an input value `x`, the accumulator function returns the current [range][range]. + +```javascript +var accumulator = incrnanrange(); + +var range = accumulator( -2.0 ); +// returns 0.0 + +range = accumulator( NaN ); +// returns 0.0 (ignores NaN) + +range = accumulator( 1.0 ); +// returns 3.0 + +range = accumulator( 3.0 ); +// returns 5.0 + +range = accumulator(); +// returns 5.0 +``` + +
+ + + +
+ +## Notes + +- Input values are **not** type checked. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function. +- Unlike `incrrange`, `incrnanrange` ignores `NaN` values, ensuring they do not affect the computed range. + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var incrnanrange = require( '@stdlib/stats/incr/nanrange' ); + +var accumulator; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanrange(); + +// For each simulated datum, update the range... +for ( i = 0; i < 100; i++ ) { + v = randu() > 0.1 ? randu() * 100.0 : NaN; // Introduce some NaNs + accumulator( v ); +} +console.log( accumulator() ); +``` + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanrange/benchmark/benchmark.js new file mode 100644 index 000000000000..075be9d97ca4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/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 incrnanrange = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var f; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = incrnanrange(); + 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 = incrnanrange(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = acc( randu()*10.0 ); + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt new file mode 100644 index 000000000000..31c286a70f88 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt @@ -0,0 +1,30 @@ +{{alias}}() + Returns an accumulator function which incrementally computes a range, ignoring + `NaN` values. + + If provided a value, the accumulator function returns an updated range. If + not provided a value, the accumulator function returns the current range. + + Returns + ------- + acc: Function + Accumulator function. + + Examples + -------- + > var accumulator = {{alias}}(); + > var v = accumulator() + null + > v = accumulator( -2.0 ) + 0.0 + > v = accumulator( NaN ) + 0.0 + > v = accumulator( 3.0 ) + 5.0 + > v = accumulator( 1.0 ) + 5.0 + > v = accumulator() + 5.0 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/index.d.ts new file mode 100644 index 000000000000..b98137b0f976 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/index.d.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. +*/ + +// TypeScript Version: 4.1 + +/// + +/** +* If provided a value, returns an updated range; otherwise, returns the current range. +* +* ## Notes +* +* - If provided `NaN` or a value which, when used in computations, results in `NaN`, the accumulated value is `NaN` for all future invocations. +* +* @param x - value +* @returns range +*/ +type accumulator = ( x?: number ) => number | null; + +/** +* Returns an accumulator function which incrementally computes a range. +* +* @returns accumulator function +* +* @example +* var accumulator = incrnanrange(); +* +* var v = accumulator(); +* // returns null +* +* v = accumulator( 2.0 ); +* // returns 0.0 +* +* v = accumulator( -1.0 ); +* // returns 3.0 +* +* v = accumulator( NaN ); +* // returns 3.0 +* +* v = accumulator( -3.0 ); +* // returns 5.0 +* +* v = accumulator(); +* // returns 5.0 +*/ +declare function incrnanrange(): accumulator; + + +// EXPORTS // + +export = incrnanrange; diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/test.ts new file mode 100644 index 000000000000..dc87d6f8a00f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/test.ts @@ -0,0 +1,61 @@ +/* +* @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 incrnanrange = require( './index' ); + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnanrange(); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided arguments... +{ + incrnanrange( '5' ); // $ExpectError + incrnanrange( 5 ); // $ExpectError + incrnanrange( true ); // $ExpectError + incrnanrange( false ); // $ExpectError + incrnanrange( null ); // $ExpectError + incrnanrange( undefined ); // $ExpectError + incrnanrange( [] ); // $ExpectError + incrnanrange( {} ); // $ExpectError + incrnanrange( ( x: number ): number => x ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnanrange(); + + 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 = incrnanrange(); + + 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/nanrange/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js new file mode 100644 index 000000000000..35f5a6b27340 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js @@ -0,0 +1,43 @@ +/** +* @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 incrnanrange = require( './../lib' ); + +var accumulator; +var range; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanrange(); + +// For each simulated datum, update the range... +console.log( '\nValue\tRange\n' ); +for ( i = 0; i < 100; i++ ) { + if ( randu() < 0.2 ) { + v = NaN; + } else { + v = randu() * 100.0; + } + range = accumulator( v ); + console.log( '%d\t%d', v.toFixed( 4 ), ( range === null ) ? NaN : range.toFixed( 4 ) ); +} +console.log( '\nFinal range: %d\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/libs/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/libs/index.js new file mode 100644 index 000000000000..8128594330c8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/libs/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 range incrementally, ignoring `NaN` values. +* +* @module @stdlib/stats/incr/nanrange +* +* @example +* var incrnanrange = require( '@stdlib/stats/incr/nanrange' ); +* +* var accumulator = incrnanrange(); +* +* var range = accumulator(); +* // returns null +* +* range = accumulator( 3.14 ); +* // returns 0.0 +* +* range = accumulator( NaN ); +* // returns 8.14 +* +* range = accumulator( -5.0 ); +* // returns 8.14 +* +* range = accumulator( 10.1 ); +* // returns 15.1 +* +* range = accumulator(); +* // returns 15.1 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js b/lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js new file mode 100644 index 000000000000..f4cc320395cb --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js @@ -0,0 +1,91 @@ +/** +* @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 PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes a range while ignoring NaN values. +* +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrnanrange(); +* +* var range = accumulator(); +* // returns null +* +* range = accumulator( 3.14 ); +* // returns 0.0 +* +* range = accumulator( NaN ); +* // returns 0.0 +* +* range = accumulator( -5.0 ); +* // returns 8.14 +* +* range = accumulator( 10.1 ); +* // returns 15.1 +* +* range = accumulator(); +* // returns 15.1 +*/ +function incrnanrange() { + var range; + var max = NINF; + var min = PINF; + + return accumulator; + + /** + * If provided a value, the accumulator function returns an updated range while ignoring NaN values. 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 ) { + return ( range === void 0 ) ? null : range; + } + if ( isnan( x ) ) { + return range; + } + if ( x > max ) { + max = x; + } + if ( x < min ) { + min = x; + } + range = max - min; + return range; + } +} + + +// EXPORTS // + +module.exports = incrnanrange; diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/package.json b/lib/node_modules/@stdlib/stats/incr/nanrange/package.json new file mode 100644 index 000000000000..cc23dfe3f6f7 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/stats/incr/nanrange", + "version": "0.0.0", + "description": "Compute a range incrementally, ignoring NaN values.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "mathematics", + "math", + "maximum", + "max", + "minimum", + "min", + "range", + "dispersion", + "variance", + "domain", + "extent", + "incremental", + "accumulator" + ] + } + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js new file mode 100644 index 000000000000..fae93831eda1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js @@ -0,0 +1,112 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var incrnanrange = require( './../lib' ); + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrnanrange, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.equal( typeof incrnanrange(), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'if not provided any values, the initial returned range is `null`', function test( t ) { + var acc = incrnanrange(); + t.equal( acc(), null, 'returns null' ); + t.end(); +}); + +tape( 'the accumulator function incrementally computes a range while ignoring NaN values', function test( t ) { + var expected; + var actual; + var data; + var acc; + var max; + var min; + var N; + var d; + var i; + + data = [ 2.0, 3.0, NaN, 2.0, 4.0, NaN, 3.0, 4.0 ]; + N = data.length; + + expected = new Array( N ); + actual = new Array( N ); + + acc = incrnanrange(); + + max = null; + min = null; + for ( i = 0; i < N; i++ ) { + d = data[ i ]; + if ( isnan( d ) === false ) { + if ( max === null || d > max ) { + max = d; + } + if ( min === null || d < min ) { + min = d; + } + expected[ i ] = max - min; + } else { + expected[ i ] = expected[i-1]; + } + actual[ i ] = acc( d ); + } + 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, NaN, 3.0, 1.0, NaN ]; + acc = incrnanrange(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); + } + t.equal( acc(), 5.0, 'returns the current accumulated range' ); + t.end(); +}); + +tape( 'if provided a `NaN`, the accumulator function returns `NaN` for all future invocations', function test( t ) { + var data; + var acc; + var i; + + data = [ 2.0, NaN, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ]; + acc = incrnanrange(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); + } + t.equal( isnan( acc() ), true, 'returns expected value' ); + t.end(); +}); From 9ab186960376a85518f314e4e92721c3d0e01734 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 2 Mar 2025 10:32:49 +0530 Subject: [PATCH 02/20] changes --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/stats/incr/nanrange/lib/index.js | 57 ++++++++++++ .../@stdlib/stats/incr/nanrange/lib/main.js | 91 +++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/lib/main.js diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js new file mode 100644 index 000000000000..4f98db152303 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/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 range incrementally, ignoring `NaN` values. +* +* @module @stdlib/stats/incr/nanrange +* +* @example +* var incrnanrange = require( '@stdlib/stats/incr/nanrange' ); +* +* var accumulator = incrnanrange(); +* +* var range = accumulator(); +* // returns null +* +* range = accumulator( 3.14 ); +* // returns 0.0 +* +* range = accumulator( NaN ); +* // returns 8.14 +* +* range = accumulator( -5.0 ); +* // returns 8.14 +* +* range = accumulator( 10.1 ); +* // returns 15.1 +* +* range = accumulator(); +* // returns 15.1 +*/ + +// MODULES // + +var main = require( '@stdlib/stats/incr/nanrange/lib/main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/main.js new file mode 100644 index 000000000000..f4cc320395cb --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/main.js @@ -0,0 +1,91 @@ +/** +* @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 PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes a range while ignoring NaN values. +* +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrnanrange(); +* +* var range = accumulator(); +* // returns null +* +* range = accumulator( 3.14 ); +* // returns 0.0 +* +* range = accumulator( NaN ); +* // returns 0.0 +* +* range = accumulator( -5.0 ); +* // returns 8.14 +* +* range = accumulator( 10.1 ); +* // returns 15.1 +* +* range = accumulator(); +* // returns 15.1 +*/ +function incrnanrange() { + var range; + var max = NINF; + var min = PINF; + + return accumulator; + + /** + * If provided a value, the accumulator function returns an updated range while ignoring NaN values. 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 ) { + return ( range === void 0 ) ? null : range; + } + if ( isnan( x ) ) { + return range; + } + if ( x > max ) { + max = x; + } + if ( x < min ) { + min = x; + } + range = max - min; + return range; + } +} + + +// EXPORTS // + +module.exports = incrnanrange; From 9cdec3c6156776c34bb33ae47a8eff19405a8df6 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Fri, 7 Mar 2025 20:21:43 +0530 Subject: [PATCH 03/20] update the test case --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- .../@stdlib/stats/incr/nanrange/test/test.js | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js index fae93831eda1..40661395a6e9 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js @@ -54,11 +54,11 @@ tape( 'the accumulator function incrementally computes a range while ignoring Na var d; var i; - data = [ 2.0, 3.0, NaN, 2.0, 4.0, NaN, 3.0, 4.0 ]; + data = [ 2.0, NaN, 3.0, NaN, 4.0, 43.0, NaN, 4.0 ]; N = data.length; - expected = new Array( N ); - actual = new Array( N ); + expected = []; + actual = []; acc = incrnanrange(); @@ -66,29 +66,27 @@ tape( 'the accumulator function incrementally computes a range while ignoring Na min = null; for ( i = 0; i < N; i++ ) { d = data[ i ]; - if ( isnan( d ) === false ) { + if ( !isnan( d ) ) { if ( max === null || d > max ) { max = d; } if ( min === null || d < min ) { min = d; } - expected[ i ] = max - min; - } else { - expected[ i ] = expected[i-1]; } - actual[ i ] = acc( d ); + expected.push( max !== null && min !== null ? max - min : null ); + actual.push( acc( d ) ); } 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 ) { +tape( 'if not provided an input value, the accumulator function returns the current range while ignoring the NaN value', function test( t ) { var data; var acc; var i; - data = [ -2.0, NaN, 3.0, 1.0, NaN ]; + data = [ NaN, -2.0, NaN, 3.0, 1.0 ]; acc = incrnanrange(); for ( i = 0; i < data.length; i++ ) { acc( data[ i ] ); @@ -107,6 +105,20 @@ tape( 'if provided a `NaN`, the accumulator function returns `NaN` for all futur for ( i = 0; i < data.length; i++ ) { acc( data[ i ] ); } - t.equal( isnan( acc() ), true, 'returns expected value' ); + t.equal( isnan( acc() ), false, 'returns expected value' ); + t.end(); +}); + +tape( 'if all provided values are `NaN`, the accumulator function returns `null`', function test( t ) { + var data; + var acc; + var i; + + data = [ NaN, NaN, NaN ]; + acc = incrnanrange(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); + } + t.equal( acc(), null, 'returns null' ); t.end(); }); From 6737ce1f7c99c129bfba31a952416be551773089 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Fri, 7 Mar 2025 21:10:39 +0530 Subject: [PATCH 04/20] updated the main.js --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js b/lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js index f4cc320395cb..8ef0f95dfa9b 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js @@ -57,6 +57,7 @@ function incrnanrange() { var range; var max = NINF; var min = PINF; + var hasValidValue = false; return accumulator; @@ -69,7 +70,7 @@ function incrnanrange() { */ function accumulator( x ) { if ( arguments.length === 0 ) { - return ( range === void 0 ) ? null : range; + return hasValidValue ? range : null; } if ( isnan( x ) ) { return range; @@ -80,6 +81,7 @@ function incrnanrange() { if ( x < min ) { min = x; } + hasValidValue = true; range = max - min; return range; } From 4c1effdc516e767b843092d4894f85d43b53d225 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 09:41:57 +0530 Subject: [PATCH 05/20] resolving linting errors in readme --- lib/node_modules/@stdlib/stats/incr/nanrange/README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/README.md b/lib/node_modules/@stdlib/stats/incr/nanrange/README.md index 9a1d98de0b7e..3c07eaaa903a 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/README.md @@ -103,7 +103,7 @@ accumulator = incrnanrange(); // For each simulated datum, update the range... for ( i = 0; i < 100; i++ ) { - v = randu() > 0.1 ? randu() * 100.0 : NaN; // Introduce some NaNs + v = ( randu() > 0.1 ) ? ( randu() * 100.0 ) : NaN; accumulator( v ); } console.log( accumulator() ); @@ -136,12 +136,6 @@ console.log( accumulator() ); -[@stdlib/stats/incr/max]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/max - -[@stdlib/stats/incr/mean]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/mean - -[@stdlib/stats/incr/min]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/min - [@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 From 2b757d158e08437661da8b677996a5835e3bba8b Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 09:46:54 +0530 Subject: [PATCH 06/20] check --- lib/node_modules/@stdlib/stats/incr/nanrange/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/README.md b/lib/node_modules/@stdlib/stats/incr/nanrange/README.md index 3c07eaaa903a..d3b0029343d7 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2020 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From dea44a878a42544f2c2c99f6e5b807b53b8c1e0b Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 09:47:43 +0530 Subject: [PATCH 07/20] check --- lib/node_modules/@stdlib/stats/incr/nanrange/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/README.md b/lib/node_modules/@stdlib/stats/incr/nanrange/README.md index d3b0029343d7..2941fff903fb 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/README.md @@ -1,3 +1,4 @@ + \ No newline at end of file + From ccdf4d479a9d0374a6fdb20e314a34114beaaffd Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 09:58:06 +0530 Subject: [PATCH 10/20] small edits --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/stats/incr/nanrange/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/index.d.ts index b98137b0f976..b3b815ee6810 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/index.d.ts @@ -48,7 +48,7 @@ type accumulator = ( x?: number ) => number | null; * * v = accumulator( -1.0 ); * // returns 3.0 -* +* * v = accumulator( NaN ); * // returns 3.0 * diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js index 4f98db152303..a7f88d6b043e 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js @@ -49,7 +49,7 @@ // MODULES // -var main = require( '@stdlib/stats/incr/nanrange/lib/main.js' ); +var main = require( '@stdlib/stats/incr/nanrange' ); // EXPORTS // From bd245cebeecf21772fad18efe8feadead733b43a Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 10:01:20 +0530 Subject: [PATCH 11/20] changes --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- lib/node_modules/@stdlib/stats/incr/nanrange/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/package.json b/lib/node_modules/@stdlib/stats/incr/nanrange/package.json index cc23dfe3f6f7..5a9fc9472b68 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/package.json @@ -68,4 +68,3 @@ "accumulator" ] } - \ No newline at end of file From 14c10e50a00eb0cccd106246f464c7902633d24f Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 10:12:23 +0530 Subject: [PATCH 12/20] adding module --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js index a7f88d6b043e..4f98db152303 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js @@ -49,7 +49,7 @@ // MODULES // -var main = require( '@stdlib/stats/incr/nanrange' ); +var main = require( '@stdlib/stats/incr/nanrange/lib/main.js' ); // EXPORTS // From 8e83b6e4d9d51ae412bd507f5dde640a74cae1a5 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 10:20:18 +0530 Subject: [PATCH 13/20] update example --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js index 35f5a6b27340..1b266baa608c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js @@ -38,6 +38,6 @@ for ( i = 0; i < 100; i++ ) { v = randu() * 100.0; } range = accumulator( v ); - console.log( '%d\t%d', v.toFixed( 4 ), ( range === null ) ? NaN : range.toFixed( 4 ) ); + console.log( '%d\t%s', v.toFixed( 4 ), ( range != null && range !== undefined ) ? range.toFixed( 4 ) : 'NaN' ); } console.log( '\nFinal range: %d\n', accumulator() ); From b1efce1a3593fb689399b537394ab1f45aacf232 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 10:31:13 +0530 Subject: [PATCH 14/20] 2025 --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- .../@stdlib/stats/incr/nanrange/README.md | 2 +- .../incr/nanrange/benchmark/benchmark.js | 2 +- .../stats/incr/nanrange/docs/types/index.d.ts | 2 +- .../stats/incr/nanrange/docs/types/test.ts | 2 +- .../stats/incr/nanrange/examples/index.js | 2 +- .../@stdlib/stats/incr/nanrange/lib/index.js | 2 +- .../@stdlib/stats/incr/nanrange/lib/main.js | 2 +- .../@stdlib/stats/incr/nanrange/libs/index.js | 57 ------------ .../@stdlib/stats/incr/nanrange/libs/main.js | 93 ------------------- .../@stdlib/stats/incr/nanrange/test/test.js | 2 +- 10 files changed, 8 insertions(+), 158 deletions(-) delete mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/libs/index.js delete mode 100644 lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/README.md b/lib/node_modules/@stdlib/stats/incr/nanrange/README.md index 6f161e536faa..11d0922417a7 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2020 The Stdlib Authors. +Copyright (c) 2025 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanrange/benchmark/benchmark.js index 075be9d97ca4..55ec66038b3e 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/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/nanrange/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/index.d.ts index b3b815ee6810..ed1b80172ca1 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/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/nanrange/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/test.ts index dc87d6f8a00f..4d77a63c52db 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/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/nanrange/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js index 1b266baa608c..f65f8ebbb67a 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/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/nanrange/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js index 4f98db152303..b7236c751b2c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/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/nanrange/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/main.js index f4cc320395cb..0246ec0b2209 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/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/nanrange/libs/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/libs/index.js deleted file mode 100644 index 8128594330c8..000000000000 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/libs/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @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 range incrementally, ignoring `NaN` values. -* -* @module @stdlib/stats/incr/nanrange -* -* @example -* var incrnanrange = require( '@stdlib/stats/incr/nanrange' ); -* -* var accumulator = incrnanrange(); -* -* var range = accumulator(); -* // returns null -* -* range = accumulator( 3.14 ); -* // returns 0.0 -* -* range = accumulator( NaN ); -* // returns 8.14 -* -* range = accumulator( -5.0 ); -* // returns 8.14 -* -* range = accumulator( 10.1 ); -* // returns 15.1 -* -* range = accumulator(); -* // returns 15.1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js b/lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js deleted file mode 100644 index 8ef0f95dfa9b..000000000000 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/libs/main.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @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 PINF = require( '@stdlib/constants/float64/pinf' ); -var NINF = require( '@stdlib/constants/float64/ninf' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); - - -// MAIN // - -/** -* Returns an accumulator function which incrementally computes a range while ignoring NaN values. -* -* @returns {Function} accumulator function -* -* @example -* var accumulator = incrnanrange(); -* -* var range = accumulator(); -* // returns null -* -* range = accumulator( 3.14 ); -* // returns 0.0 -* -* range = accumulator( NaN ); -* // returns 0.0 -* -* range = accumulator( -5.0 ); -* // returns 8.14 -* -* range = accumulator( 10.1 ); -* // returns 15.1 -* -* range = accumulator(); -* // returns 15.1 -*/ -function incrnanrange() { - var range; - var max = NINF; - var min = PINF; - var hasValidValue = false; - - return accumulator; - - /** - * If provided a value, the accumulator function returns an updated range while ignoring NaN values. 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 ) { - return hasValidValue ? range : null; - } - if ( isnan( x ) ) { - return range; - } - if ( x > max ) { - max = x; - } - if ( x < min ) { - min = x; - } - hasValidValue = true; - range = max - min; - return range; - } -} - - -// EXPORTS // - -module.exports = incrnanrange; diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js index 40661395a6e9..6a4ae936be99 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/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 547e28558a162f17ceea88eda939c0ef9223089e Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 10:51:43 +0530 Subject: [PATCH 15/20] lint errors --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt | 4 ++-- lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt index 31c286a70f88..e1d07ba82bee 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}() - Returns an accumulator function which incrementally computes a range, ignoring - `NaN` values. + Returns an accumulator function which incrementally computes a range, + ignoring `NaN` values. If provided a value, the accumulator function returns an updated range. If not provided a value, the accumulator function returns the current range. diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js index b7236c751b2c..25c1698f595a 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js @@ -49,7 +49,7 @@ // MODULES // -var main = require( '@stdlib/stats/incr/nanrange/lib/main.js' ); +var main = require( '@stdlib/stats/incr/nanrange' ); // EXPORTS // From e982f2dca0a6e1258fbc85cf2739f043331e6ad7 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 10:54:35 +0530 Subject: [PATCH 16/20] lint --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js index 25c1698f595a..b7236c751b2c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js @@ -49,7 +49,7 @@ // MODULES // -var main = require( '@stdlib/stats/incr/nanrange' ); +var main = require( '@stdlib/stats/incr/nanrange/lib/main.js' ); // EXPORTS // From 3e049ad851f3798be6732d7e6de669b598e3a598 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 11:01:00 +0530 Subject: [PATCH 17/20] verify --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/stats/incr/nanrange/docs/repl.txt | 2 +- .../@stdlib/stats/incr/nanrange/examples/index.js | 14 +++++++------- .../@stdlib/stats/incr/nanrange/lib/index.js | 2 +- .../@stdlib/stats/incr/nanrange/package.json | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt index e1d07ba82bee..c399e95ae1cf 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/docs/repl.txt @@ -1,5 +1,5 @@ {{alias}}() - Returns an accumulator function which incrementally computes a range, + Returns an accumulator function which incrementally computes a range, ignoring `NaN` values. If provided a value, the accumulator function returns an updated range. If diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js index f65f8ebbb67a..3e409e56b489 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js @@ -32,12 +32,12 @@ accumulator = incrnanrange(); // For each simulated datum, update the range... console.log( '\nValue\tRange\n' ); for ( i = 0; i < 100; i++ ) { - if ( randu() < 0.2 ) { - v = NaN; - } else { - v = randu() * 100.0; - } - range = accumulator( v ); - console.log( '%d\t%s', v.toFixed( 4 ), ( range != null && range !== undefined ) ? range.toFixed( 4 ) : 'NaN' ); + if ( randu() < 0.2 ) { + v = NaN; + } else { + v = randu() * 100.0; + } + range = accumulator( v ); + console.log( '%d\t%s', v.toFixed( 4 ), ( range != null && range !== undefined ) ? range.toFixed( 4 ) : 'NaN' ); } console.log( '\nFinal range: %d\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js index b7236c751b2c..4aa2df877513 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/lib/index.js @@ -49,7 +49,7 @@ // MODULES // -var main = require( '@stdlib/stats/incr/nanrange/lib/main.js' ); +var main = require( './main.js' ); // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/package.json b/lib/node_modules/@stdlib/stats/incr/nanrange/package.json index 5a9fc9472b68..7d97899c5b65 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/package.json @@ -67,4 +67,4 @@ "incremental", "accumulator" ] - } +} From a06fb8b248f53cec76ba2562979e99c6aa48b8e5 Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 11:09:25 +0530 Subject: [PATCH 18/20] error fixed --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js index 3e409e56b489..04a353ec0fd1 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/examples/index.js @@ -38,6 +38,6 @@ for ( i = 0; i < 100; i++ ) { v = randu() * 100.0; } range = accumulator( v ); - console.log( '%d\t%s', v.toFixed( 4 ), ( range != null && range !== undefined ) ? range.toFixed( 4 ) : 'NaN' ); + console.log( '%d\t%s', v.toFixed( 4 ), ( range !== null && typeof range !== 'undefined' ) ? range.toFixed( 4 ) : 'NaN' ); } console.log( '\nFinal range: %d\n', accumulator() ); From d141f10c9ea8499453d5a7402552b04bccafea8c Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 11:14:01 +0530 Subject: [PATCH 19/20] edit --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js index 6a4ae936be99..0a64cb2e615e 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/test/test.js @@ -24,6 +24,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var incrnanrange = require( './../lib' ); + // TESTS // tape( 'main export is a function', function test( t ) { @@ -74,7 +75,7 @@ tape( 'the accumulator function incrementally computes a range while ignoring Na min = d; } } - expected.push( max !== null && min !== null ? max - min : null ); + expected.push( ( max !== null && min !== null ) ? ( max - min ) : null ); actual.push( acc( d ) ); } t.deepEqual( actual, expected, 'returns expected incremental results' ); From c9b938d478697bde71bd9045090f6363aeb0d88c Mon Sep 17 00:00:00 2001 From: jalajk3004 Date: Sun, 9 Mar 2025 11:22:13 +0530 Subject: [PATCH 20/20] update package --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/stats/incr/nanrange/package.json | 132 +++++++++--------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrange/package.json b/lib/node_modules/@stdlib/stats/incr/nanrange/package.json index 7d97899c5b65..f2408612cf2f 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrange/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanrange/package.json @@ -1,70 +1,70 @@ { - "name": "@stdlib/stats/incr/nanrange", - "version": "0.0.0", - "description": "Compute a range incrementally, ignoring NaN values.", - "license": "Apache-2.0", - "author": { + "name": "@stdlib/stats/incr/nanrange", + "version": "0.0.0", + "description": "Compute a range incrementally, while ignoring `NaN` values.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { "name": "The Stdlib Authors", "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdmath", - "statistics", - "stats", - "mathematics", - "math", - "maximum", - "max", - "minimum", - "min", - "range", - "dispersion", - "variance", - "domain", - "extent", - "incremental", - "accumulator" - ] + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "mathematics", + "math", + "maximum", + "max", + "minimum", + "min", + "range", + "dispersion", + "variance", + "domain", + "extent", + "incremental", + "accumulator" + ] }