From a35a9be94b2774678410cb1efdaa9190d5745940 Mon Sep 17 00:00:00 2001 From: Girish Garg Date: Mon, 17 Mar 2025 19:07:44 +0530 Subject: [PATCH 1/4] feat: add incremental maximum absolute value accumulator ignoring NaN values --- .../@stdlib/stats/incr/nanmaxabs/README.md | 140 ++++++++++++++++++ .../incr/nanmaxabs/benchmark/benchmark.js | 69 +++++++++ .../stats/incr/nanmaxabs/docs/repl.txt | 35 +++++ .../incr/nanmaxabs/docs/types/index.d.ts | 66 +++++++++ .../stats/incr/nanmaxabs/docs/types/test.ts | 61 ++++++++ .../stats/incr/nanmaxabs/examples/index.js | 40 +++++ .../@stdlib/stats/incr/nanmaxabs/lib/index.js | 54 +++++++ .../@stdlib/stats/incr/nanmaxabs/lib/main.js | 76 ++++++++++ .../@stdlib/stats/incr/nanmaxabs/package.json | 69 +++++++++ .../@stdlib/stats/incr/nanmaxabs/test/test.js | 112 ++++++++++++++ 10 files changed, 722 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmaxabs/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmaxabs/package.json create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md new file mode 100644 index 000000000000..fdf4af5ed91a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md @@ -0,0 +1,140 @@ + + +# incrnanmaxabs + +> Compute a maximum absolute value incrementally. + +
+ +## Usage + +```javascript +var incrnanmaxabs = require( '@stdlib/stats/incr/nanmaxabs' ); +``` + +#### incrnanmaxabs() + +Returns an accumulator `function` which incrementally computes a maximum absolute value. + +```javascript +var accumulator = incrnanmaxabs(); +``` + +#### accumulator( \[x] ) + +If provided an input value `x`, the accumulator function returns an updated maximum absolute value. If not provided an input value `x`, the accumulator function returns the current maximum absolute value. + +```javascript +var accumulator = incrnanmaxabs(); + +var max = accumulator( 2.0 ); +// returns 2.0 + +max = accumulator( 1.0 ); +// returns 2.0 + +max = accumulator( -3.0 ); +// returns 3.0 + +max = accumulator( NaN ); //Ignored +// returns 3.0 + +max = accumulator(); +// returns 3.0 +``` + +
+ + + +
+ +## Notes + +- Input values are type checked. If provided `NaN` or any value which results in `NaN`, it will be ignored but you are advised to type check and handle accordingly **before** passing the value to the accumulator function. + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var incrnanmaxabs = require( './../lib' ); + +var accumulator; +var max; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanmaxabs(); + +// For each simulated datum, update the max absolute value... +for ( i = 0; i < 100; i++ ) { + v = ( randu() < 0.2 ) ? NaN : (randu() * 100.0) - 50.0; + max = accumulator( v ); +} +console.log( accumulator() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/benchmark/benchmark.js new file mode 100644 index 000000000000..c96816695f78 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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 incrnanmaxabs = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var f; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = incrnanmaxabs(); + 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 = incrnanmaxabs(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = acc( randu()-0.5 ); + 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/nanmaxabs/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/repl.txt new file mode 100644 index 000000000000..77853b5bded1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/repl.txt @@ -0,0 +1,35 @@ + +{{alias}}() + Returns an accumulator function which incrementally computes a maximum + absolute value. + + If provided a value, the accumulator function returns an updated maximum + absolute value. If not provided a value, the accumulator function returns + the current maximum absolute value. + + If provided `NaN`, it will be ignored. + + Returns + ------- + acc: Function + Accumulator function. + + Examples + -------- + > var accumulator = {{alias}}(); + > var m = accumulator() + null + > m = accumulator( 3.14 ) + 3.14 + > m = accumulator( -5.0 ) + 5.0 + > m = accumulator( 10.1 ) + 10.1 + > m = accumulator( NaN ) + 10.1 + > m = accumulator() + 10.1 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/index.d.ts new file mode 100644 index 000000000000..61f116c8ca88 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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 maximum absolute value; otherwise, returns the current maximum absolute value. +* +* ## Notes +* +* - If provided `NaN` or a value which, when used in computations, results in `NaN`, it will be ignored. +* +* @param x - value +* @returns maximum absolute value +*/ +type accumulator = ( x?: number ) => number | null; + +/** +* Returns an accumulator function which incrementally computes a maximum absolute value. +* +* @returns accumulator function +* +* @example +* var accumulator = incrmaxabs(); +* +* var v = accumulator(); +* // returns null +* +* v = accumulator( 2.0 ); +* // returns 2.0 +* +* v = accumulator( -3.0 ); +* // returns 3.0 +* +* v = accumulator( 1.0 ); +* // returns 3.0 +* +* v = accumulator( NaN ); +* // returns 3.0 +* +* v = accumulator(); +* // returns 3.0 +*/ +declare function incrmaxabs(): accumulator; + + +// EXPORTS // + +export = incrmaxabs; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/test.ts new file mode 100644 index 000000000000..4792493033fa --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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 incrnanmaxabs = require( './index' ); + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnanmaxabs(); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided arguments... +{ + incrnanmaxabs( '5' ); // $ExpectError + incrnanmaxabs( 5 ); // $ExpectError + incrnanmaxabs( true ); // $ExpectError + incrnanmaxabs( false ); // $ExpectError + incrnanmaxabs( null ); // $ExpectError + incrnanmaxabs( undefined ); // $ExpectError + incrnanmaxabs( [] ); // $ExpectError + incrnanmaxabs( {} ); // $ExpectError + incrnanmaxabs( ( x: number ): number => x ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnanmaxabs(); + + 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 = incrnanmaxabs(); + + 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/nanmaxabs/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js new file mode 100644 index 000000000000..06ab78f94912 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js @@ -0,0 +1,40 @@ +/** +* @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 incrnanmaxabs = require( './../lib' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + +var accumulator; +var max; +var v; +var i; + +// Initialize an accumulator: +accumulator = incrnanmaxabs(); + +// For each simulated datum, update the max absolute value... +console.log( '\nValue\tMaxAbs\n' ); +for ( i = 0; i < 100; i++ ) { + v = ( randu() < 0.2 ) ? NaN : (randu() * 100.0) - 50.0; + max = accumulator( v ); + console.log( '%d\t%d', isnan(v) ? 'NaN' : v.toFixed( 3 ), max.toFixed( 3 ) ); +} +console.log( '\nFinal maximum absolute value: %d\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js new file mode 100644 index 000000000000..9d400d7ede2c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js @@ -0,0 +1,54 @@ +/** +* @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 maximum absolute value incrementally. +* +* @module @stdlib/stats/incr/nanmaxabs +* +* @example +* var incrnanmaxabs = require( '@stdlib/stats/incr/nanmaxabs' ); +* +* var accumulator = incrnanmaxabs(); +* +* var max = accumulator(); +* // returns null +* +* max = accumulator( 3.14 ); +* // returns 3.14 +* +* max = accumulator( -5.0 ); +* // returns 5.0 +* +* max = accumulator( 10.1 ); +* // returns 10.1 +* +* max = accumulator(); +* // returns 10.1 +*/ + +// MODULES // + +var main = require( '@stdlib/stats/incr/nanmaxabs/lib/main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js new file mode 100644 index 000000000000..e307974d80ec --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js @@ -0,0 +1,76 @@ +/** +* @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 incrmaxabs = require( '@stdlib/stats/incr/maxabs' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes a maximum absolute value, ignoring `NaN` value. +* +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrnanmaxabs(); +* +* var max = accumulator(); +* // returns null +* +* max = accumulator( 3.14 ); +* // returns 3.14 +* +* max = accumulator( -5.0 ); +* // returns 5.0 +* +* max = accumulator( 10.1 ); +* // returns 10.1 +* +* max = accumulator( NaN ); //Ignored +* // returns 10.1 +* +* max = accumulator(); +* // returns 10.1 +*/ +function incrnanmaxabs() { + var max = incrmaxabs(); + return accumulator; + + /** + * If provided a value, the accumulator function returns an updated maximum absolute value. If not provided a value, the accumulator function returns the current maximum absolute value. + * + * @private + * @param {number} [x] - new value + * @returns {(number|null)} maximum absolute value or null + */ + function accumulator( x ) { + if ( arguments.length === 0 || isnan(x) ) { + return max(); + } + return max( x ); + } +} + + +// EXPORTS // + +module.exports = incrnanmaxabs; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/package.json b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/package.json new file mode 100644 index 000000000000..3a2d6bcc54f2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/stats/incr/nanmaxabs", + "version": "0.0.0", + "description": "Compute a maximum absolute value 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", + "abs", + "absolute", + "range", + "extremes", + "domain", + "extent", + "incremental", + "accumulator" + ] +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js new file mode 100644 index 000000000000..4bbbc19087bd --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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 isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var incrmaxabs = require( '@stdlib/stats/incr/nanmaxabs/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrmaxabs, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.equal( typeof incrmaxabs(), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'if not provided any values, the initial returned maximum absolute value is `null`', function test( t ) { + var acc = incrmaxabs(); + t.equal( acc(), null, 'returns null' ); + t.end(); +}); + +tape( 'the accumulator function incrementally computes a maximum absolute value', function test( t ) { + var expected; + var actual; + var data; + var acc; + var max; + var ad; + 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 = incrmaxabs(); + + max = data[ 0 ]; + for ( i = 0; i < N; i++ ) { + d = data[ i ]; + ad = abs( d ); + if ( ad > max ) { + max = ad; + } + expected[ i ] = max; + 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 maximum absolute value', function test( t ) { + var data; + var acc; + var i; + + data = [ 2.0, NaN, -3.0, 1.0 ]; + acc = incrmaxabs(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); + } + t.equal( acc(), 3.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the accumulator function correctly handles signed zeros', function test( t ) { + var acc; + var v; + + acc = incrmaxabs(); + + v = acc( -0.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + + v = acc( 0.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + + v = acc( -0.0 ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); + + t.end(); +}); + From cdbdb43325437b41eeedf64e06a8ae778fbf93fe Mon Sep 17 00:00:00 2001 From: Girish Garg Date: Wed, 23 Apr 2025 18:04:15 +0530 Subject: [PATCH 2/4] Fixed linting errors --- .../@stdlib/stats/incr/nanmaxabs/examples/index.js | 11 ++++++++--- .../@stdlib/stats/incr/nanmaxabs/lib/index.js | 2 +- .../@stdlib/stats/incr/nanmaxabs/lib/main.js | 1 + .../@stdlib/stats/incr/nanmaxabs/test/test.js | 9 ++++----- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js index 06ab78f94912..28e081098117 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js @@ -19,8 +19,8 @@ 'use strict'; var randu = require( '@stdlib/random/base/randu' ); -var incrnanmaxabs = require( './../lib' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var incrnanmaxabs = require( './../lib' ); var accumulator; var max; @@ -33,8 +33,13 @@ accumulator = incrnanmaxabs(); // For each simulated datum, update the max absolute value... console.log( '\nValue\tMaxAbs\n' ); for ( i = 0; i < 100; i++ ) { - v = ( randu() < 0.2 ) ? NaN : (randu() * 100.0) - 50.0; + if ( randu() < 0.2 ) { + v = NaN; + } + else { + v = ( randu() * 100.0 ) - 50.0; + } max = accumulator( v ); - console.log( '%d\t%d', isnan(v) ? 'NaN' : v.toFixed( 3 ), max.toFixed( 3 ) ); + console.log( '%d\t%d', ( isnan(v) ) ? 'NaN' : v.toFixed( 3 ), max.toFixed( 3 ) ); } console.log( '\nFinal maximum absolute value: %d\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js index 9d400d7ede2c..dc250f236f29 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js @@ -46,7 +46,7 @@ // MODULES // -var main = require( '@stdlib/stats/incr/nanmaxabs/lib/main.js' ); +var main = require( './main.js' ); // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js index e307974d80ec..e29c778273cc 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js @@ -23,6 +23,7 @@ var incrmaxabs = require( '@stdlib/stats/incr/maxabs' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); + // MAIN // /** diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js index 4bbbc19087bd..b50f7f4e4fb0 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js @@ -59,8 +59,8 @@ tape( 'the accumulator function incrementally computes a maximum absolute value' 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 ); + expected = []; + actual = []; acc = incrmaxabs(); @@ -71,8 +71,8 @@ tape( 'the accumulator function incrementally computes a maximum absolute value' if ( ad > max ) { max = ad; } - expected[ i ] = max; - actual[ i ] = acc( d ); + expected.push(max); + actual.push(acc( d )); } t.deepEqual( actual, expected, 'returns expected incremental results' ); t.end(); @@ -109,4 +109,3 @@ tape( 'the accumulator function correctly handles signed zeros', function test( t.end(); }); - From 0fb330eb515d0ba3af4ff602cad83bc1920bd0ab Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Wed, 23 Apr 2025 13:13:48 +0000 Subject: [PATCH 3/4] chore: update copyright years --- lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md | 2 +- .../@stdlib/stats/incr/nanmaxabs/benchmark/benchmark.js | 2 +- .../@stdlib/stats/incr/nanmaxabs/docs/types/index.d.ts | 2 +- .../@stdlib/stats/incr/nanmaxabs/docs/types/test.ts | 2 +- lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md index fdf4af5ed91a..727b913dcaac 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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/nanmaxabs/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/benchmark/benchmark.js index c96816695f78..a7c9967ced72 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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/nanmaxabs/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/index.d.ts index 61f116c8ca88..2f639b576c82 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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/nanmaxabs/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/test.ts index 4792493033fa..df0d981e2c49 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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/nanmaxabs/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js index 28e081098117..dddd4307a5c4 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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/nanmaxabs/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js index dc250f236f29..245ba1f3a4ee 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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/nanmaxabs/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js index e29c778273cc..06a62e9b5c0f 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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/nanmaxabs/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js index b50f7f4e4fb0..355953541fba 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/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 2d894812cdbd35e543c8c0899eaf29fb9f322346 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 29 Apr 2025 00:58:10 -0700 Subject: [PATCH 4/4] chore: clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/incr/nanmaxabs/README.md | 48 +++++-------------- .../incr/nanmaxabs/benchmark/benchmark.js | 3 +- .../stats/incr/nanmaxabs/docs/repl.txt | 8 ++-- .../incr/nanmaxabs/docs/types/index.d.ts | 10 ++-- .../stats/incr/nanmaxabs/examples/index.js | 23 ++++----- .../@stdlib/stats/incr/nanmaxabs/lib/index.js | 5 +- .../@stdlib/stats/incr/nanmaxabs/lib/main.js | 10 ++-- .../@stdlib/stats/incr/nanmaxabs/package.json | 2 +- .../@stdlib/stats/incr/nanmaxabs/test/test.js | 19 ++------ 9 files changed, 42 insertions(+), 86 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md index 727b913dcaac..461c45fd0fc3 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/README.md @@ -8,7 +8,7 @@ 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 + 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, @@ -20,7 +20,7 @@ limitations under the License. # incrnanmaxabs -> Compute a maximum absolute value incrementally. +> Compute a maximum absolute value incrementally, ignoring `NaN` values.
@@ -32,7 +32,7 @@ var incrnanmaxabs = require( '@stdlib/stats/incr/nanmaxabs' ); #### incrnanmaxabs() -Returns an accumulator `function` which incrementally computes a maximum absolute value. +Returns an accumulator function which incrementally computes a maximum absolute value, ignoring `NaN` values. ```javascript var accumulator = incrnanmaxabs(); @@ -51,10 +51,10 @@ var max = accumulator( 2.0 ); max = accumulator( 1.0 ); // returns 2.0 -max = accumulator( -3.0 ); -// returns 3.0 +max = accumulator( NaN ); +// returns 2.0 -max = accumulator( NaN ); //Ignored +max = accumulator( -3.0 ); // returns 3.0 max = accumulator(); @@ -69,7 +69,7 @@ max = accumulator(); ## Notes -- Input values are type checked. If provided `NaN` or any value which results in `NaN`, it will be ignored but you are advised to type check and handle accordingly **before** passing the value to the accumulator function. +- 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.
@@ -82,21 +82,17 @@ max = accumulator(); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var incrnanmaxabs = require( './../lib' ); - -var accumulator; -var max; -var v; -var i; +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var incrnanmaxabs = require( '@stdlib/stats/incr/nanmaxabs' ); // Initialize an accumulator: -accumulator = incrnanmaxabs(); +var accumulator = incrnanmaxabs(); // For each simulated datum, update the max absolute value... +var i; for ( i = 0; i < 100; i++ ) { - v = ( randu() < 0.2 ) ? NaN : (randu() * 100.0) - 50.0; - max = accumulator( v ); + accumulator( ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -50.0, 50.0 ) ); } console.log( accumulator() ); ``` @@ -109,14 +105,6 @@ console.log( accumulator() ); @@ -125,16 +113,6 @@ console.log( accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/benchmark/benchmark.js index a7c9967ced72..e1045443c8d4 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/benchmark/benchmark.js @@ -21,7 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var pkg = require( './../package.json' ).name; var incrnanmaxabs = require( './../lib' ); @@ -55,7 +54,7 @@ bench( pkg+'::accumulator', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = acc( randu()-0.5 ); + v = acc( i ); if ( v !== v ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/repl.txt index 77853b5bded1..efac41bb4582 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/repl.txt @@ -1,14 +1,12 @@ {{alias}}() Returns an accumulator function which incrementally computes a maximum - absolute value. + absolute value, ignoring `NaN` values. If provided a value, the accumulator function returns an updated maximum absolute value. If not provided a value, the accumulator function returns the current maximum absolute value. - If provided `NaN`, it will be ignored. - Returns ------- acc: Function @@ -23,9 +21,9 @@ 3.14 > m = accumulator( -5.0 ) 5.0 - > m = accumulator( 10.1 ) - 10.1 > m = accumulator( NaN ) + 5.0 + > m = accumulator( 10.1 ) 10.1 > m = accumulator() 10.1 diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/index.d.ts index 2f639b576c82..a28b957a035f 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/docs/types/index.d.ts @@ -23,17 +23,13 @@ /** * If provided a value, returns an updated maximum absolute value; otherwise, returns the current maximum absolute value. * -* ## Notes -* -* - If provided `NaN` or a value which, when used in computations, results in `NaN`, it will be ignored. -* * @param x - value * @returns maximum absolute value */ type accumulator = ( x?: number ) => number | null; /** -* Returns an accumulator function which incrementally computes a maximum absolute value. +* Returns an accumulator function which incrementally computes a maximum absolute value, ignoring `NaN` values. * * @returns accumulator function * @@ -49,10 +45,10 @@ type accumulator = ( x?: number ) => number | null; * v = accumulator( -3.0 ); * // returns 3.0 * -* v = accumulator( 1.0 ); +* v = accumulator( NaN ); * // returns 3.0 * -* v = accumulator( NaN ); +* v = accumulator( 1.0 ); * // returns 3.0 * * v = accumulator(); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js index dddd4307a5c4..ef8f11228c6a 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/examples/index.js @@ -18,28 +18,21 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var incrnanmaxabs = require( './../lib' ); -var accumulator; -var max; -var v; -var i; - // Initialize an accumulator: -accumulator = incrnanmaxabs(); +var accumulator = incrnanmaxabs(); // For each simulated datum, update the max absolute value... console.log( '\nValue\tMaxAbs\n' ); +var max; +var v; +var i; for ( i = 0; i < 100; i++ ) { - if ( randu() < 0.2 ) { - v = NaN; - } - else { - v = ( randu() * 100.0 ) - 50.0; - } + v = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -50.0, 50.0 ); max = accumulator( v ); - console.log( '%d\t%d', ( isnan(v) ) ? 'NaN' : v.toFixed( 3 ), max.toFixed( 3 ) ); + console.log( '%d\t%d', v.toFixed( 4 ), ( max === null ) ? NaN : max.toFixed( 3 ) ); } console.log( '\nFinal maximum absolute value: %d\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js index 245ba1f3a4ee..adbeb37542cb 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Compute a maximum absolute value incrementally. +* Compute a maximum absolute value incrementally, ignoring `NaN` values. * * @module @stdlib/stats/incr/nanmaxabs * @@ -37,6 +37,9 @@ * max = accumulator( -5.0 ); * // returns 5.0 * +* max = accumulator( NaN ); +* // returns 5.0 +* * max = accumulator( 10.1 ); * // returns 10.1 * diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js index 06a62e9b5c0f..8dc6256bddc9 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/lib/main.js @@ -27,7 +27,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); // MAIN // /** -* Returns an accumulator function which incrementally computes a maximum absolute value, ignoring `NaN` value. +* Returns an accumulator function which incrementally computes a maximum absolute value, ignoring `NaN` values. * * @returns {Function} accumulator function * @@ -43,10 +43,10 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * max = accumulator( -5.0 ); * // returns 5.0 * -* max = accumulator( 10.1 ); -* // returns 10.1 +* max = accumulator( NaN ); +* // returns 5.0 * -* max = accumulator( NaN ); //Ignored +* max = accumulator( 10.1 ); * // returns 10.1 * * max = accumulator(); @@ -64,7 +64,7 @@ function incrnanmaxabs() { * @returns {(number|null)} maximum absolute value or null */ function accumulator( x ) { - if ( arguments.length === 0 || isnan(x) ) { + if ( arguments.length === 0 || isnan( x ) ) { return max(); } return max( x ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/package.json b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/package.json index 3a2d6bcc54f2..a5284bd9ef9b 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/stats/incr/nanmaxabs", "version": "0.0.0", - "description": "Compute a maximum absolute value incrementally.", + "description": "Compute a maximum absolute value incrementally, ignoring NaN values.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js index 355953541fba..169072da259c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmaxabs/test/test.js @@ -22,8 +22,7 @@ var tape = require( 'tape' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var incrmaxabs = require( '@stdlib/stats/incr/nanmaxabs/lib' ); +var incrmaxabs = require( './../lib' ); // TESTS // @@ -39,7 +38,7 @@ tape( 'the function returns an accumulator function', function test( t ) { t.end(); }); -tape( 'if not provided any values, the initial returned maximum absolute value is `null`', function test( t ) { +tape( 'the initial accumulated value is `null`', function test( t ) { var acc = incrmaxabs(); t.equal( acc(), null, 'returns null' ); t.end(); @@ -50,29 +49,19 @@ tape( 'the accumulator function incrementally computes a maximum absolute value' var actual; var data; var acc; - var max; - var ad; 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 = []; + expected = [ 2.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0 ]; actual = []; acc = incrmaxabs(); - max = data[ 0 ]; for ( i = 0; i < N; i++ ) { - d = data[ i ]; - ad = abs( d ); - if ( ad > max ) { - max = ad; - } - expected.push(max); - actual.push(acc( d )); + actual.push( acc( data[ i ] ) ); } t.deepEqual( actual, expected, 'returns expected incremental results' ); t.end();