From 0f2c4d6209b084c45830d18f1b4e8508d39d2f8d Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 00:54:37 +0530 Subject: [PATCH 01/13] Added @stdlib/math/base/special/nanmin --- .../math/base/special/nanmin/README.md | 118 ++++++++++++++++++ .../special/nanmin/benchmark/benchmark.js | 56 +++++++++ .../math/base/special/nanmin/docs/repl.txt | 33 +++++ .../base/special/nanmin/docs/types/index.d.ts | 45 +++++++ .../base/special/nanmin/docs/types/test.ts | 51 ++++++++ .../base/special/nanmin/examples/index.js | 35 ++++++ .../math/base/special/nanmin/lib/index.js | 46 +++++++ .../math/base/special/nanmin/lib/main.js | 64 ++++++++++ .../math/base/special/nanmin/package.json | 61 +++++++++ .../math/base/special/nanmin/test/test.js | 68 ++++++++++ 10 files changed, 577 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/README.md b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md new file mode 100644 index 000000000000..d75e3d98e57d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md @@ -0,0 +1,118 @@ + + +# nanmin + +> If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var nanmin = require( '@stdlib/math/base/special/nanmin' ); +``` + +#### nanmin( x, y ) + +Returns the minimum value. + +```javascript +var v = nanmin( 4.2, 3.14 ); +// returns 3.14 + +v = nanmin( +0.0, -0.0 ); +// returns -0.0 +``` + +If any argument is `NaN`, the function returns `other operand`. + +```javascript +var v = nanmin( 4.2, NaN ); +// returns 4.2 + +v = nanmin( NaN, 3.14 ); +// returns 3.14 +``` + + +If both argument is `NaN`, the function returns `NaN`. + +```javascript +var v = nanmin( NaN, NaN ); +// returns NaN + +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js new file mode 100644 index 000000000000..2a899e10b3bd --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -0,0 +1,56 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var nanmin = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var z; + var i; + + values = [3, 2, 1.0, 1.5, NaN]; + x = 0.4 + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = values[ i%values.length ]; + z = nanmin( x, y ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt new file mode 100644 index 000000000000..ab3e572596ad --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt @@ -0,0 +1,33 @@ + +{{alias}}( x, y ) + Returns the minimum value. + + If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. + + Parameters + ---------- + x: number + First number. + + y: number + Second number. + + Returns + ------- + out: number + Minimum value. + + Examples + -------- + > var v = {{alias}}( 3.14, 4.2 ) + 3.14 + > v = {{alias}}( 3.14, NaN ) + 3.14 + > v = {{alias}}( NaN, 4.2 ) + 4.2 + > v = {{alias}}( NaN, NaN ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts new file mode 100644 index 000000000000..37cb184f8fcb --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts @@ -0,0 +1,45 @@ +/* +* @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 one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* +* @param x - first number +* @param y - second number +* @returns minimum value +* +* @example +* var v = min( 3.14, 4.2 ); +* // returns 3.14 +* +* @example +* var v = min( 3.14, NaN ); +* // returns 3.14 +* +* @example +* var v = min( NaN, NaN ); +* // returns NaN +*/ +declare function nanmin( x: number, y: number ): number; + + +// EXPORTS // + +export = nanmin; diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts new file mode 100644 index 000000000000..73fefa8f9c8d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts @@ -0,0 +1,51 @@ +/* +* @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 nanmin = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + nanmin( 3.0, -0.2 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided non-number arguments... +{ + nanmin( true, 3.0 ); // $ExpectError + nanmin( false, 3.0 ); // $ExpectError + nanmin( [], 3.0 ); // $ExpectError + nanmin( {}, 3.0 ); // $ExpectError + nanmin( 'abc', 3.0 ); // $ExpectError + nanmin( ( x: number ): number => x, 3.0 ); // $ExpectError + + nanmin( 1.2, true ); // $ExpectError + nanmin( 1.2, false ); // $ExpectError + nanmin( 1.2, [] ); // $ExpectError + nanmin( 1.2, {} ); // $ExpectError + nanmin( 1.2, 'abc' ); // $ExpectError + nanmin( 1.2, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + nanmin(); // $ExpectError + nanmin( 3.0 ); // $ExpectError + nanmin( 3.0, 2.0, 1.0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js new file mode 100644 index 000000000000..52a704e03442 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -0,0 +1,35 @@ +/** +* @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 nanmin = require( './../lib' ); + + +var m = nanmin( 3.0, 4.0 ); +// returns 3.0 + +m = nanmin( NaN, 4.0 ); +// returns 4.0 + +m = nanmin( 3.0, NaN ); +// returns 3.0 + +m = nanmin( NaN, NaN ); +// returns NaN \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js new file mode 100644 index 000000000000..bbd1025b68c9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js @@ -0,0 +1,46 @@ +/** +* @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'; + +/** +* If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* +* @module @stdlib/math/base/special/nanmin +* +* @example +* var nanmin = require( '@stdlib/math/base/special/nanmin' ); +* +* var v = nanmin( 3.14, 4.2 ); +* // returns 3.14 +* +* v = nanmin( 3.14, NaN ); +* // returns 3.14 +* +* v = nanmin( NaN, NaN ); +* // returns NaN +*/ + +// MODULES // + +var nanmin = require( './main.js' ); + + +// EXPORTS // + +module.exports = nanmin; diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js new file mode 100644 index 000000000000..c251ee562843 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -0,0 +1,64 @@ +/** +* @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 min = require( '@stdlib/math/base/special/min' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + + +// MAIN // + +/** +* If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* +* @param {number} x - first number +* @param {number} y - second number +* @returns {number} minimum value +* +* @example +* var v = nanmin( 3.14, 4.2 ); +* // returns 3.14 +* +* @example +* var v = nanmin( 3.14, NaN ); +* // returns 3.14 +* +* @example +* var v = nanmin( NaN, NaN); +* // returns NaN +*/ +function nanmin( x, y ) { + if (isnan(x) && isnan(y)) { + return NaN; + } else if (isnan(x)) { + return y; + } else if (isnan(y)) { + return x; + } else { + return min(x, y); + } +} + + +// EXPORTS // + +module.exports = nanmin; diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/package.json b/lib/node_modules/@stdlib/math/base/special/nanmin/package.json new file mode 100644 index 000000000000..6561ccab2695 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/package.json @@ -0,0 +1,61 @@ +{ + "name": "@stdlib/math/base/special/nanmin", + "version": "0.0.0", + "description": "If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum", + "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", + "mathematics", + "math", + "math.min", + "minimum", + "min", + "smallest" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js new file mode 100644 index 000000000000..03d07866ad49 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js @@ -0,0 +1,68 @@ +/** +* @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 nanmin = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nanmin, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if both operands are `NaN`', function test( t ) { + var v; + + v = nanmin( NaN, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + + t.end(); +}); + +tape( 'the function returns `Not NaN Value` if one of the operand is `NaN`', function test( t ) { + var v; + + v = nanmin( NaN, 3.14 ); + t.strictEqual( v, 3.14, 'returns not NaN value' ); + + v = nanmin( 4.2, NaN ); + t.strictEqual( v, 4.2, 'returns not NaN value' ); + + t.end(); +}); + +tape( 'the function returns the minimum value', function test( t ) { + var v; + + v = nanmin( 4.2, 3.14 ); + t.strictEqual( v, 3.14, 'returns min value' ); + + v = nanmin( -4.2, 3.14 ); + t.strictEqual( v, -4.2, 'returns min value' ); + + t.end(); +}); From d144bb4acd8b26dbf3fdfe7158b339519a2bbe47 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 07:29:32 +0530 Subject: [PATCH 02/13] Added @stdlib/math/base/special/nanmin --- .../@stdlib/math/base/special/nanmin/benchmark/benchmark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js index 2a899e10b3bd..d2ce2fe7a13e 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -21,7 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var nanmin = require( './../lib' ); @@ -30,6 +29,7 @@ var nanmin = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { + var values; var x; var y; var z; From 78d82a3774d8bb757aa612237d7bc87be59496a2 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 09:38:46 +0530 Subject: [PATCH 03/13] Added @stdlib/math/base/special/nanmin --- .../math/base/special/nanmin/lib/main.js | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js index c251ee562843..174e291728c8 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -20,10 +20,8 @@ // MODULES // -var min = require( '@stdlib/math/base/special/min' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); - - +var min = require( '@stdlib/math/base/special/min'); +var isnan = require( '@stdlib/math/base/assert/is-nan'); // MAIN // @@ -48,17 +46,17 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); */ function nanmin( x, y ) { if (isnan(x) && isnan(y)) { - return NaN; - } else if (isnan(x)) { - return y; - } else if (isnan(y)) { - return x; - } else { - return min(x, y); - } + return NaN; + } + if (isnan(x)) { + return y; + } + if (isnan(y)) { + return x; + } + return min(x, y); } - // EXPORTS // module.exports = nanmin; From cf88b61225b761d1a6903eeea964cbb2ddadb0b9 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 13:04:02 +0530 Subject: [PATCH 04/13] Added @stdlib/math/base/special/nanmin --- lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt index ab3e572596ad..e44b922864f1 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt @@ -2,7 +2,7 @@ {{alias}}( x, y ) Returns the minimum value. - If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. + If one operand is NaN, the other operand is always returned. Parameters ---------- From 4a1e103bd2020e737a4d632a255c9402791814f8 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 15:22:52 +0530 Subject: [PATCH 05/13] Added @stdlib/math/base/special/nanmin --- lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js index 174e291728c8..5ee1298e434e 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -23,6 +23,7 @@ var min = require( '@stdlib/math/base/special/min'); var isnan = require( '@stdlib/math/base/assert/is-nan'); + // MAIN // /** @@ -57,6 +58,7 @@ function nanmin( x, y ) { return min(x, y); } + // EXPORTS // module.exports = nanmin; From aeb3795b92b3918f54efe6ef6da59834a9f25c63 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 15:31:16 +0530 Subject: [PATCH 06/13] Added @stdlib/math/base/special/nanmin --- .../@stdlib/math/base/special/nanmin/examples/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js index 52a704e03442..d2a07d7272fa 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -18,18 +18,20 @@ 'use strict'; - var nanmin = require( './../lib' ); - var m = nanmin( 3.0, 4.0 ); +console.log(m) // returns 3.0 m = nanmin( NaN, 4.0 ); +console.log(m) // returns 4.0 m = nanmin( 3.0, NaN ); +console.log(m) // returns 3.0 m = nanmin( NaN, NaN ); -// returns NaN \ No newline at end of file +console.log(m) +// returns NaN From 4ff14fc45659ee3b522c00e8ec839da7861d96cd Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 15:36:18 +0530 Subject: [PATCH 07/13] Added @stdlib/math/base/special/nanmin --- .../@stdlib/math/base/special/nanmin/examples/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js index d2a07d7272fa..2e550b25f77e 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -21,17 +21,15 @@ var nanmin = require( './../lib' ); var m = nanmin( 3.0, 4.0 ); -console.log(m) // returns 3.0 m = nanmin( NaN, 4.0 ); -console.log(m) // returns 4.0 m = nanmin( 3.0, NaN ); -console.log(m) // returns 3.0 m = nanmin( NaN, NaN ); -console.log(m) // returns NaN + +console.log(m); From b1edc3deef8afe46a80e0bb64a65638527b910a7 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 20:16:13 +0530 Subject: [PATCH 08/13] feat: added @stdlib/math/base/special/nanmin --- .../@stdlib/math/base/special/nanmin/benchmark/benchmark.js | 3 +-- .../@stdlib/math/base/special/nanmin/test/test.js | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js index d2ce2fe7a13e..fa985f7862ca 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -36,7 +36,7 @@ bench( pkg, function benchmark( b ) { var i; values = [3, 2, 1.0, 1.5, NaN]; - x = 0.4 + x = 0.4; b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -53,4 +53,3 @@ bench( pkg, function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); }); - diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js index 03d07866ad49..df1f99225fc8 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js @@ -37,9 +37,7 @@ tape( 'the function returns `NaN` if both operands are `NaN`', function test( t var v; v = nanmin( NaN, NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - + t.strictEqual( isnan( v ), true, 'returns NaN value' ); t.end(); }); From 6460912a33b35ff616ae200f4d37e36fa48c7f85 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 22:37:49 +0530 Subject: [PATCH 09/13] feat: added @stdlib/math/base/special/nanmin --- .../@stdlib/math/base/special/nanmin/benchmark/benchmark.js | 2 +- .../@stdlib/math/base/special/nanmin/docs/types/index.d.ts | 4 ++-- .../@stdlib/math/base/special/nanmin/docs/types/test.ts | 2 +- .../@stdlib/math/base/special/nanmin/examples/index.js | 4 ++-- .../@stdlib/math/base/special/nanmin/lib/index.js | 4 ++-- lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js | 4 ++-- .../@stdlib/math/base/special/nanmin/test/test.js | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js index fa985f7862ca..6f8ccfece1b5 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -35,7 +35,7 @@ bench( pkg, function benchmark( b ) { var z; var i; - values = [3, 2, 1.0, 1.5, NaN]; + values = [3, 2, 2.0, 1.5, NaN]; x = 0.4; b.tic(); diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts index 37cb184f8fcb..d20b1b45e0a7 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts @@ -30,8 +30,8 @@ * // returns 3.14 * * @example -* var v = min( 3.14, NaN ); -* // returns 3.14 +* var v = min( 4.14, NaN ); +* // returns 4.14 * * @example * var v = min( NaN, NaN ); diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts index 73fefa8f9c8d..08f7f8316fef 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts @@ -23,7 +23,7 @@ import nanmin = require( './index' ); // The function returns a number... { - nanmin( 3.0, -0.2 ); // $ExpectType number + nanmin( 3.0, -0.4 ); // $ExpectType number } // The compiler throws an error if the function is provided non-number arguments... diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js index 2e550b25f77e..07c39ba4c2bb 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -26,8 +26,8 @@ var m = nanmin( 3.0, 4.0 ); m = nanmin( NaN, 4.0 ); // returns 4.0 -m = nanmin( 3.0, NaN ); -// returns 3.0 +m = nanmin( 4.0, NaN ); +// returns 4.0 m = nanmin( NaN, NaN ); // returns NaN diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js index bbd1025b68c9..2e58997f7496 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js @@ -29,8 +29,8 @@ * var v = nanmin( 3.14, 4.2 ); * // returns 3.14 * -* v = nanmin( 3.14, NaN ); -* // returns 3.14 +* v = nanmin( 4.14, NaN ); +* // returns 4.14 * * v = nanmin( NaN, NaN ); * // returns NaN diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js index 5ee1298e434e..31b447bf9832 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -38,8 +38,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan'); * // returns 3.14 * * @example -* var v = nanmin( 3.14, NaN ); -* // returns 3.14 +* var v = nanmin( 4.14, NaN ); +* // returns 4.14 * * @example * var v = nanmin( NaN, NaN); diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js index df1f99225fc8..9c43540f20fc 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js @@ -56,7 +56,7 @@ tape( 'the function returns `Not NaN Value` if one of the operand is `NaN`', fun tape( 'the function returns the minimum value', function test( t ) { var v; - v = nanmin( 4.2, 3.14 ); + v = nanmin( 5.2, 3.14 ); t.strictEqual( v, 3.14, 'returns min value' ); v = nanmin( -4.2, 3.14 ); From 5ccd941caa6aa5c9f4482dbe6264ec3fb2bf77bd Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sun, 9 Jun 2024 21:16:39 +0000 Subject: [PATCH 10/13] chore: update copyright years --- .../@stdlib/math/base/special/nanmin/benchmark/benchmark.js | 2 +- .../@stdlib/math/base/special/nanmin/docs/types/index.d.ts | 2 +- .../@stdlib/math/base/special/nanmin/docs/types/test.ts | 2 +- .../@stdlib/math/base/special/nanmin/examples/index.js | 2 +- lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js | 2 +- lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js | 2 +- lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js index 6f8ccfece1b5..8b958a5fa262 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 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/math/base/special/nanmin/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts index d20b1b45e0a7..8db73944a607 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2024 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/math/base/special/nanmin/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts index 08f7f8316fef..660f6c323428 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2024 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/math/base/special/nanmin/examples/index.js b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js index 07c39ba4c2bb..2d8bb2b500ea 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 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/math/base/special/nanmin/lib/index.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js index 2e58997f7496..19088dc05b06 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 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/math/base/special/nanmin/lib/main.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js index 31b447bf9832..1ef5d97b8281 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 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/math/base/special/nanmin/test/test.js b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js index 9c43540f20fc..cead9d86f692 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 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 4a4f8f307e983e9a7b84bc143bdc663811633743 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Mon, 10 Jun 2024 13:10:11 +0530 Subject: [PATCH 11/13] feat: added @stdlib/math/base/special/nanmin --- .../math/base/special/nanmin/benchmark/benchmark.js | 2 +- .../math/base/special/nanmin/docs/types/index.d.ts | 2 +- .../@stdlib/math/base/special/nanmin/lib/index.js | 2 +- .../@stdlib/math/base/special/nanmin/lib/main.js | 12 +++--------- .../@stdlib/math/base/special/nanmin/package.json | 2 +- .../@stdlib/math/base/special/nanmin/test/test.js | 2 +- 6 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js index 6f8ccfece1b5..03fd4e293b57 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -35,7 +35,7 @@ bench( pkg, function benchmark( b ) { var z; var i; - values = [3, 2, 2.0, 1.5, NaN]; + values = [ 3, 2, 2.0, 1.5, NaN ]; x = 0.4; b.tic(); diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts index d20b1b45e0a7..0e8d6823248c 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /** -* If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* Return the minimum value, ignoring NaN. * * @param x - first number * @param y - second number diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js index 2e58997f7496..5ca03f5f3b5b 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* Return the minimum value, ignoring NaN. * * @module @stdlib/math/base/special/nanmin * diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js index 31b447bf9832..1d1979cb0e51 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -27,7 +27,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan'); // MAIN // /** -* If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* Return the minimum value, ignoring NaN. * * @param {number} x - first number * @param {number} y - second number @@ -46,16 +46,10 @@ var isnan = require( '@stdlib/math/base/assert/is-nan'); * // returns NaN */ function nanmin( x, y ) { - if (isnan(x) && isnan(y)) { - return NaN; - } if (isnan(x)) { - return y; - } - if (isnan(y)) { - return x; + return (( isnan(y) ) ? NaN : y); } - return min(x, y); + return (( isnan(y) ) ? x : min(x, y)); } diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/package.json b/lib/node_modules/@stdlib/math/base/special/nanmin/package.json index 6561ccab2695..7edce079bd16 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/package.json +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/math/base/special/nanmin", "version": "0.0.0", - "description": "If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum", + "description": "Returns the minimum value, ignoring NaN.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js index 9c43540f20fc..1f2dfef30096 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js @@ -41,7 +41,7 @@ tape( 'the function returns `NaN` if both operands are `NaN`', function test( t t.end(); }); -tape( 'the function returns `Not NaN Value` if one of the operand is `NaN`', function test( t ) { +tape( 'the function returns the non-NaN value if one of the operands is `NaN`', function test( t ) { var v; v = nanmin( NaN, 3.14 ); From 4a8425eb4609949085b65bf95a813e1d3f6f7a6c Mon Sep 17 00:00:00 2001 From: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> Date: Mon, 10 Jun 2024 13:25:14 +0530 Subject: [PATCH 12/13] feat: added @stdlib/math/base/special/nanmin Signed-off-by: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> --- .../math/base/special/nanmin/README.md | 42 ++----------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/README.md b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md index d75e3d98e57d..abfff4de8715 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md @@ -20,7 +20,7 @@ limitations under the License. # nanmin -> If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum +> Return the minimum value, ignoring NaN. @@ -52,7 +52,7 @@ v = nanmin( +0.0, -0.0 ); // returns -0.0 ``` -If any argument is `NaN`, the function returns `other operand`. +If any argument is `NaN`, the function returns the other operand. ```javascript var v = nanmin( 4.2, NaN ); @@ -63,7 +63,7 @@ v = nanmin( NaN, 3.14 ); ``` -If both argument is `NaN`, the function returns `NaN`. +If both argument are `NaN`, the function returns `NaN`. ```javascript var v = nanmin( NaN, NaN ); @@ -80,39 +80,3 @@ var v = nanmin( NaN, NaN );
- - - - - - - - - - - - - - From 0118ae03354de2247ede1f8fc8240167462b3178 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 10 Jun 2024 08:57:49 -0400 Subject: [PATCH 13/13] Update lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js Signed-off-by: Philipp Burckhardt --- .../@stdlib/math/base/special/nanmin/lib/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js index 647a77e91446..6ab28cabb103 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -46,10 +46,10 @@ var isnan = require( '@stdlib/math/base/assert/is-nan'); * // returns NaN */ function nanmin( x, y ) { - if (isnan(x)) { - return (( isnan(y) ) ? NaN : y); + if ( isnan( x ) ) { + return ( isnan(y) ) ? NaN : y; } - return (( isnan(y) ) ? x : min(x, y)); + return ( isnan( y ) ) ? x : min( x, y ); }