From b0d5141aebba33470eeefe4a9566cb76757c1330 Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Fri, 7 Aug 2026 19:09:32 +0530 Subject: [PATCH 1/9] feat: add float16 dtype support to array/min-dtype --- 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_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - 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: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - 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: passed - task: lint_license_headers status: passed --- --- .../@stdlib/array/min-dtype/README.md | 2 +- .../@stdlib/array/min-dtype/docs/repl.txt | 2 +- .../array/min-dtype/docs/types/index.d.ts | 2 +- .../@stdlib/array/min-dtype/lib/main.js | 57 ++++++++++++++----- .../@stdlib/array/min-dtype/package.json | 3 + .../@stdlib/array/min-dtype/test/test.js | 12 ++-- 6 files changed, 56 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/array/min-dtype/README.md b/lib/node_modules/@stdlib/array/min-dtype/README.md index c2e706a06a78..f6c2e7e6217a 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/README.md +++ b/lib/node_modules/@stdlib/array/min-dtype/README.md @@ -46,7 +46,7 @@ Returns the minimum array [data type][@stdlib/array/dtypes] of the closest "kind ```javascript var dt = minDataType( 3.141592653589793 ); -// returns 'float32' +// returns 'float16' dt = minDataType( -3 ); // returns 'int8' diff --git a/lib/node_modules/@stdlib/array/min-dtype/docs/repl.txt b/lib/node_modules/@stdlib/array/min-dtype/docs/repl.txt index 56df9cf1ca14..566fe7b75fa3 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/min-dtype/docs/repl.txt @@ -21,7 +21,7 @@ Examples -------- > var dt = {{alias}}( 3.141592653589793 ) - 'float32' + 'float16' > dt = {{alias}}( 3 ) 'uint8' > dt = {{alias}}( -3 ) diff --git a/lib/node_modules/@stdlib/array/min-dtype/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/min-dtype/docs/types/index.d.ts index e2c68295eaac..fe2b12cddc65 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/min-dtype/docs/types/index.d.ts @@ -35,7 +35,7 @@ import { ComplexLike } from '@stdlib/types/complex'; * * @example * var dt = minDataType( 3.141592653589793 ); -* // returns 'float32' +* // returns 'float16' * * @example * var dt = minDataType( 3 ); diff --git a/lib/node_modules/@stdlib/array/min-dtype/lib/main.js b/lib/node_modules/@stdlib/array/min-dtype/lib/main.js index 5342fcafab31..d926ea867854 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/lib/main.js +++ b/lib/node_modules/@stdlib/array/min-dtype/lib/main.js @@ -27,6 +27,10 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); +var FLOAT16_SMALLEST_SUBNORMAL = require( '@stdlib/constants/float16/smallest-subnormal' ); // eslint-disable-line id-length +var FLOAT16_MAX_SAFE_INTEGER = require( '@stdlib/constants/float16/max-safe-integer' ); +var FLOAT16_MIN_SAFE_INTEGER = require( '@stdlib/constants/float16/min-safe-integer' ); +var FLOAT16_MAX = require( '@stdlib/constants/float16/max' ); var FLOAT32_SMALLEST_SUBNORMAL = require( '@stdlib/constants/float32/smallest-subnormal' ); // eslint-disable-line id-length var FLOAT32_MAX_SAFE_INTEGER = require( '@stdlib/constants/float32/max-safe-integer' ); var FLOAT32_MIN_SAFE_INTEGER = require( '@stdlib/constants/float32/min-safe-integer' ); @@ -49,22 +53,40 @@ var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); */ function minFloatDataType( value ) { if ( value !== value || value === PINF || value === NINF ) { - return 'float32'; + return 'float16'; } if ( isInteger( value ) ) { - if ( value >= FLOAT32_MIN_SAFE_INTEGER && value <= FLOAT32_MAX_SAFE_INTEGER ) { // eslint-disable-line max-len + if ( + value >= FLOAT16_MIN_SAFE_INTEGER && + value <= FLOAT16_MAX_SAFE_INTEGER + ) { + return 'float16'; + } + if ( + value >= FLOAT32_MIN_SAFE_INTEGER && + value <= FLOAT32_MAX_SAFE_INTEGER + ) { return 'float32'; } return 'float64'; } - // Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float32`... + // Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float16`... if ( - value > -FLOAT32_SMALLEST_SUBNORMAL && - value < FLOAT32_SMALLEST_SUBNORMAL + value > -FLOAT16_SMALLEST_SUBNORMAL && + value < FLOAT16_SMALLEST_SUBNORMAL ) { - return 'float64'; + if ( + value > -FLOAT32_SMALLEST_SUBNORMAL && + value < FLOAT32_SMALLEST_SUBNORMAL + ) { + return 'float64'; + } + return 'float32'; } // Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)... + if ( value >= -FLOAT16_MAX && value <= FLOAT16_MAX ) { + return 'float16'; + } return 'float32'; } @@ -79,7 +101,7 @@ function minFloatDataType( value ) { * * @example * var dt = minDataType( 3.141592653589793 ); -* // returns 'float32' +* // returns 'float16' * * @example * var dt = minDataType( 3 ); @@ -99,11 +121,11 @@ function minDataType( value ) { return 'generic'; } if ( value !== value || value === PINF || value === NINF ) { - return 'float32'; + return 'float16'; } if ( isInteger( value ) ) { if ( value === 0 && isNegativeZero( value ) ) { - return 'float32'; + return 'float16'; } if ( value < 0 ) { if ( value >= INT8_MIN ) { @@ -128,14 +150,23 @@ function minDataType( value ) { } return 'float64'; } - // Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float32`... + // Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float16`... if ( - value > -FLOAT32_SMALLEST_SUBNORMAL && - value < FLOAT32_SMALLEST_SUBNORMAL + value > -FLOAT16_SMALLEST_SUBNORMAL && + value < FLOAT16_SMALLEST_SUBNORMAL ) { - return 'float64'; + if ( + value > -FLOAT32_SMALLEST_SUBNORMAL && + value < FLOAT32_SMALLEST_SUBNORMAL + ) { + return 'float64'; + } + return 'float32'; } // Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)... + if ( value >= -FLOAT16_MAX && value <= FLOAT16_MAX ) { + return 'float16'; + } return 'float32'; } diff --git a/lib/node_modules/@stdlib/array/min-dtype/package.json b/lib/node_modules/@stdlib/array/min-dtype/package.json index d14b50df207c..a49b3d3fa6f1 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/package.json +++ b/lib/node_modules/@stdlib/array/min-dtype/package.json @@ -58,6 +58,9 @@ "memory", "minimum", "dtype", + "float16", + "half", + "half-precision", "utilities", "utility", "utils", diff --git a/lib/node_modules/@stdlib/array/min-dtype/test/test.js b/lib/node_modules/@stdlib/array/min-dtype/test/test.js index 7dab65e18b3d..109fd24457e7 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/test/test.js +++ b/lib/node_modules/@stdlib/array/min-dtype/test/test.js @@ -157,10 +157,10 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne } ]; expected = [ - 'float32', + 'float16', 'uint8', 'uint8', - 'float32', + 'float16', 'uint8', 'int8', 'uint16', @@ -169,14 +169,14 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne 'int32', 'float64', 'float64', - 'float32', - 'float32', + 'float16', + 'float16', 'float64', 'float64', 'float64', 'float64', - 'float32', - 'float32', + 'float16', + 'float16', 'generic', 'generic', 'bool', From dd2677f809d836700367fc788b1c3037e7547b37 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sun, 9 Aug 2026 13:11:55 +0530 Subject: [PATCH 2/9] fix: update comments and JsDOC --- 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_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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 --- --- lib/node_modules/@stdlib/array/min-dtype/lib/index.js | 2 +- lib/node_modules/@stdlib/array/min-dtype/lib/main.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/array/min-dtype/lib/index.js b/lib/node_modules/@stdlib/array/min-dtype/lib/index.js index c81b6d32387e..00824bfd4e8a 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/lib/index.js +++ b/lib/node_modules/@stdlib/array/min-dtype/lib/index.js @@ -27,7 +27,7 @@ * var minDataType = require( '@stdlib/array/min-dtype' ); * * var dt = minDataType( 3.141592653589793 ); -* // returns 'float32' +* // returns 'float16' * * dt = minDataType( 3 ); * // returns 'uint8' diff --git a/lib/node_modules/@stdlib/array/min-dtype/lib/main.js b/lib/node_modules/@stdlib/array/min-dtype/lib/main.js index d926ea867854..27d0a3cc0069 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/lib/main.js +++ b/lib/node_modules/@stdlib/array/min-dtype/lib/main.js @@ -83,7 +83,7 @@ function minFloatDataType( value ) { } return 'float32'; } - // Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)... + // Any number which reaches this point is checked against the maximum half-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~65504)... if ( value >= -FLOAT16_MAX && value <= FLOAT16_MAX ) { return 'float16'; } @@ -163,7 +163,7 @@ function minDataType( value ) { } return 'float32'; } - // Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)... + // Any number which reaches this point is checked against the maximum half-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~65504)... if ( value >= -FLOAT16_MAX && value <= FLOAT16_MAX ) { return 'float16'; } From 9a4fbca6ea164e6a1ca7cfbb48176c6bca679f6e Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 9 Aug 2026 03:25:56 -0700 Subject: [PATCH 3/9] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/array/min-dtype/lib/main.js | 6 ++++-- lib/node_modules/@stdlib/array/min-dtype/package.json | 3 --- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/array/min-dtype/lib/main.js b/lib/node_modules/@stdlib/array/min-dtype/lib/main.js index 27d0a3cc0069..c16e124a1569 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/lib/main.js +++ b/lib/node_modules/@stdlib/array/min-dtype/lib/main.js @@ -70,7 +70,7 @@ function minFloatDataType( value ) { } return 'float64'; } - // Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float16`... + // Assume that if we are provided a tiny value, we don't want to underflow to zero by storing in a smaller precision... if ( value > -FLOAT16_SMALLEST_SUBNORMAL && value < FLOAT16_SMALLEST_SUBNORMAL @@ -87,6 +87,7 @@ function minFloatDataType( value ) { if ( value >= -FLOAT16_MAX && value <= FLOAT16_MAX ) { return 'float16'; } + // Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)... return 'float32'; } @@ -150,7 +151,7 @@ function minDataType( value ) { } return 'float64'; } - // Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float16`... + // Assume that if we are provided a tiny value, we don't want to underflow to zero by storing in a smaller precision... if ( value > -FLOAT16_SMALLEST_SUBNORMAL && value < FLOAT16_SMALLEST_SUBNORMAL @@ -167,6 +168,7 @@ function minDataType( value ) { if ( value >= -FLOAT16_MAX && value <= FLOAT16_MAX ) { return 'float16'; } + // Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)... return 'float32'; } diff --git a/lib/node_modules/@stdlib/array/min-dtype/package.json b/lib/node_modules/@stdlib/array/min-dtype/package.json index a49b3d3fa6f1..d14b50df207c 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/package.json +++ b/lib/node_modules/@stdlib/array/min-dtype/package.json @@ -58,9 +58,6 @@ "memory", "minimum", "dtype", - "float16", - "half", - "half-precision", "utilities", "utility", "utils", From d67dd8137ef112000ef5ff2a154883234661578f Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 9 Aug 2026 03:28:10 -0700 Subject: [PATCH 4/9] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/array/min-dtype/lib/main.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/array/min-dtype/lib/main.js b/lib/node_modules/@stdlib/array/min-dtype/lib/main.js index c16e124a1569..1083c673e28d 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/lib/main.js +++ b/lib/node_modules/@stdlib/array/min-dtype/lib/main.js @@ -83,7 +83,6 @@ function minFloatDataType( value ) { } return 'float32'; } - // Any number which reaches this point is checked against the maximum half-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~65504)... if ( value >= -FLOAT16_MAX && value <= FLOAT16_MAX ) { return 'float16'; } @@ -164,7 +163,6 @@ function minDataType( value ) { } return 'float32'; } - // Any number which reaches this point is checked against the maximum half-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~65504)... if ( value >= -FLOAT16_MAX && value <= FLOAT16_MAX ) { return 'float16'; } From 45970b1018ed16e69d5ed1d8253584bdd1707857 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 9 Aug 2026 03:46:23 -0700 Subject: [PATCH 5/9] test: add test cases Signed-off-by: Athan --- .../@stdlib/array/min-dtype/test/test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/node_modules/@stdlib/array/min-dtype/test/test.js b/lib/node_modules/@stdlib/array/min-dtype/test/test.js index 109fd24457e7..788e03a2815c 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/test/test.js +++ b/lib/node_modules/@stdlib/array/min-dtype/test/test.js @@ -57,8 +57,12 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne -4294967297, 3.14, -3.14, + 1.0e20, // >10**5 + -1.0e20, 1.0e40, // >10**38 -1.0e40, + -1.0e-10, // <10**-7 + 1.0e-10, -1.0e-46, // <10**-45 1.0e-46, PINF, @@ -94,6 +98,10 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne new Complex128( 1.0e40, 1.0 ), new Complex128( 1.0, -1.0e40 ), new Complex128( 1.0, 1.0e40 ), + new Complex128( -1.0e10, 1.0 ), + new Complex128( 1.0e10, 1.0 ), + new Complex128( 1.0, -1.0e10 ), + new Complex128( 1.0, 1.0e10 ), { 're': 3.0, @@ -171,8 +179,12 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne 'float64', 'float16', 'float16', + 'float32', + 'float32', 'float64', 'float64', + 'float32', + 'float32', 'float64', 'float64', 'float16', @@ -208,6 +220,10 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne 'complex128', 'complex128', 'complex128', + 'complex64', + 'complex64', + 'complex64', + 'complex64', 'complex64', 'complex128', From 1d0155793fae4334bd16e50461d6e4c440bb58da Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 9 Aug 2026 03:51:59 -0700 Subject: [PATCH 6/9] test: update tests Signed-off-by: Athan --- .../@stdlib/array/min-dtype/test/test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/array/min-dtype/test/test.js b/lib/node_modules/@stdlib/array/min-dtype/test/test.js index 788e03a2815c..2b7d2321f1b1 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/test/test.js +++ b/lib/node_modules/@stdlib/array/min-dtype/test/test.js @@ -179,8 +179,8 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne 'float64', 'float16', 'float16', - 'float32', - 'float32', + 'float64', + 'float64', 'float64', 'float64', 'float32', @@ -220,10 +220,10 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne 'complex128', 'complex128', 'complex128', - 'complex64', - 'complex64', - 'complex64', - 'complex64', + 'complex128', + 'complex128', + 'complex128', + 'complex128', 'complex64', 'complex128', From dbe51c1fd4082964347d5b5ef59de481367e189b Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 9 Aug 2026 03:52:52 -0700 Subject: [PATCH 7/9] test: add test cases Signed-off-by: Athan --- lib/node_modules/@stdlib/array/min-dtype/test/test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/node_modules/@stdlib/array/min-dtype/test/test.js b/lib/node_modules/@stdlib/array/min-dtype/test/test.js index 2b7d2321f1b1..331e1f49ae96 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/test/test.js +++ b/lib/node_modules/@stdlib/array/min-dtype/test/test.js @@ -102,6 +102,10 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne new Complex128( 1.0e10, 1.0 ), new Complex128( 1.0, -1.0e10 ), new Complex128( 1.0, 1.0e10 ), + new Complex128( -1.0e-10, 1.0 ), + new Complex128( 1.0e-10, 1.0 ), + new Complex128( 1.0, -1.0e-10 ), + new Complex128( 1.0, 1.0e-10 ), { 're': 3.0, @@ -224,6 +228,10 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne 'complex128', 'complex128', 'complex128', + 'complex64', + 'complex64', + 'complex64', + 'complex64', 'complex64', 'complex128', From eb513cb4463ba991108d5a4df028ac74a1c1c08a Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Mon, 10 Aug 2026 15:27:21 +0530 Subject: [PATCH 8/9] test: add test cases for float32 value ranges --- 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_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - 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/array/min-dtype/test/test.js | 110 +++++++++++++----- 1 file changed, 78 insertions(+), 32 deletions(-) diff --git a/lib/node_modules/@stdlib/array/min-dtype/test/test.js b/lib/node_modules/@stdlib/array/min-dtype/test/test.js index 331e1f49ae96..768438951919 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/test/test.js +++ b/lib/node_modules/@stdlib/array/min-dtype/test/test.js @@ -36,7 +36,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value', function test( t ) { +tape( 'the function returns the minimum array data type of the closest "kind" necessary for storing a provided real scalar value', function test( t ) { var expected; var actual; var values; @@ -57,6 +57,8 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne -4294967297, 3.14, -3.14, + 70000.5, + -70000.5, 1.0e20, // >10**5 -1.0e20, 1.0e40, // >10**38 @@ -71,7 +73,55 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne {}, true, false, - [], + [] + ]; + expected = [ + 'float16', + 'uint8', + 'uint8', + 'float16', + 'uint8', + 'int8', + 'uint16', + 'int16', + 'uint32', + 'int32', + 'float64', + 'float64', + 'float16', + 'float16', + 'float32', + 'float32', + 'float64', + 'float64', + 'float64', + 'float64', + 'float32', + 'float32', + 'float64', + 'float64', + 'float16', + 'float16', + 'generic', + 'generic', + 'bool', + 'bool', + 'generic' + ]; + for ( i = 0; i < values.length; i++ ) { + actual = minDataType( values[i] ); + t.strictEqual( actual, expected[ i ], 'returns expected value when provided '+values[i] ); + } + t.end(); +}); + +tape( 'the function returns the minimum array data type of the closest "kind" necessary for storing a provided complex number or other value', function test( t ) { + var expected; + var actual; + var values; + var i; + + values = [ new Complex64( 3.0, 5.0 ), new Complex128( 3.0, 5.0 ), new Complex64( 1.0, 1.0 ), @@ -106,6 +156,14 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne new Complex128( 1.0e-10, 1.0 ), new Complex128( 1.0, -1.0e-10 ), new Complex128( 1.0, 1.0e-10 ), + new Complex128( -70000.5, 1.0 ), + new Complex128( 70000.5, 1.0 ), + new Complex128( 1.0, -70000.5 ), + new Complex128( 1.0, 70000.5 ), + new Complex128( -30000, 1.0 ), + new Complex128( 30000, 1.0 ), + new Complex128( 1.0, -30000 ), + new Complex128( 1.0, 30000 ), { 're': 3.0, @@ -166,38 +224,17 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne { 're': 3.0, 'im': 3.14 + }, + { + 're': 70000.5, + 'im': 5.0 + }, + { + 're': 3.0, + 'im': 70000.5 } ]; expected = [ - 'float16', - 'uint8', - 'uint8', - 'float16', - 'uint8', - 'int8', - 'uint16', - 'int16', - 'uint32', - 'int32', - 'float64', - 'float64', - 'float16', - 'float16', - 'float64', - 'float64', - 'float64', - 'float64', - 'float32', - 'float32', - 'float64', - 'float64', - 'float16', - 'float16', - 'generic', - 'generic', - 'bool', - 'bool', - 'generic', 'complex64', 'complex64', 'complex64', @@ -232,6 +269,14 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne 'complex64', 'complex64', 'complex64', + 'complex64', + 'complex64', + 'complex64', + 'complex64', + 'complex64', + 'complex64', + 'complex64', + 'complex64', 'complex64', 'complex128', @@ -247,8 +292,9 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne 'complex64', 'complex64', 'complex64', + 'complex64', + 'complex64', 'complex64' - ]; for ( i = 0; i < values.length; i++ ) { actual = minDataType( values[i] ); From fdd7c9e5aee2f16d9e4bf1e22741246c491bea0c Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 10 Aug 2026 16:44:50 -0700 Subject: [PATCH 9/9] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/array/min-dtype/test/test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/array/min-dtype/test/test.js b/lib/node_modules/@stdlib/array/min-dtype/test/test.js index 768438951919..5e42b1fdd769 100644 --- a/lib/node_modules/@stdlib/array/min-dtype/test/test.js +++ b/lib/node_modules/@stdlib/array/min-dtype/test/test.js @@ -160,10 +160,10 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne new Complex128( 70000.5, 1.0 ), new Complex128( 1.0, -70000.5 ), new Complex128( 1.0, 70000.5 ), - new Complex128( -30000, 1.0 ), - new Complex128( 30000, 1.0 ), - new Complex128( 1.0, -30000 ), - new Complex128( 1.0, 30000 ), + new Complex128( -30000.0, 1.0 ), + new Complex128( 30000.0, 1.0 ), + new Complex128( 1.0, -30000.0 ), + new Complex128( 1.0, 30000.0 ), { 're': 3.0,