From 02e665c630f261be0f07509a33cba7bbe99ad46b Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Mon, 10 Aug 2026 13:25:30 +0530 Subject: [PATCH 1/2] feat: add float16 dtype support to array/convert --- 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: passed - task: lint_python status: missing_dependencies - 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 --- --- .../array/convert/benchmark/benchmark.js | 25 +++++++++++++++++++ .../convert/benchmark/benchmark.length.js | 3 +++ .../convert/benchmark/julia/benchmark.jl | 1 + .../benchmark/python/numpy/benchmark.py | 1 + .../@stdlib/array/convert/docs/types/test.ts | 1 + .../@stdlib/array/convert/test/test.js | 14 +++++++++++ 6 files changed, 45 insertions(+) diff --git a/lib/node_modules/@stdlib/array/convert/benchmark/benchmark.js b/lib/node_modules/@stdlib/array/convert/benchmark/benchmark.js index 805eb8352a70..6e1adb168ea9 100644 --- a/lib/node_modules/@stdlib/array/convert/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/array/convert/benchmark/benchmark.js @@ -104,6 +104,31 @@ bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { b.end(); }); +bench( format( '%s:dtype=float16', pkg ), function benchmark( b ) { + var arr; + var out; + var i; + + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( i ); + } + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr[ 0 ] += 1; + out = convertArray( arr, 'float16' ); + if ( out.length !== arr.length ) { + b.fail( 'should have expected length' ); + } + } + b.toc(); + if ( !isCollection( out ) ) { + b.fail( 'should return an array-like object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { var arr; var out; diff --git a/lib/node_modules/@stdlib/array/convert/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/convert/benchmark/benchmark.length.js index 1e2030cb0146..bdac310b0f93 100644 --- a/lib/node_modules/@stdlib/array/convert/benchmark/benchmark.length.js +++ b/lib/node_modules/@stdlib/array/convert/benchmark/benchmark.length.js @@ -104,6 +104,9 @@ function main() { f = createBenchmark( len, 'float32' ); bench( format( '%s:len=%d,dtype=float32', pkg, len ), f ); + f = createBenchmark( len, 'float16' ); + bench( format( '%s:len=%d,dtype=float16', pkg, len ), f ); + f = createBenchmark( len, 'bool' ); bench( format( '%s:len=%d,dtype=bool', pkg, len ), f ); diff --git a/lib/node_modules/@stdlib/array/convert/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/array/convert/benchmark/julia/benchmark.jl index ee2aa5682a76..1518afd467a4 100755 --- a/lib/node_modules/@stdlib/array/convert/benchmark/julia/benchmark.jl +++ b/lib/node_modules/@stdlib/array/convert/benchmark/julia/benchmark.jl @@ -169,6 +169,7 @@ function main() dtypes = [ Float64, Float32, + Float16, Int32, Int16, Int8, diff --git a/lib/node_modules/@stdlib/array/convert/benchmark/python/numpy/benchmark.py b/lib/node_modules/@stdlib/array/convert/benchmark/python/numpy/benchmark.py index 6660853b6e55..abb86e5f6305 100755 --- a/lib/node_modules/@stdlib/array/convert/benchmark/python/numpy/benchmark.py +++ b/lib/node_modules/@stdlib/array/convert/benchmark/python/numpy/benchmark.py @@ -107,6 +107,7 @@ def main(): dtypes = [ "float64", "float32", + "float16", "int32", "int16", "int8", diff --git a/lib/node_modules/@stdlib/array/convert/docs/types/test.ts b/lib/node_modules/@stdlib/array/convert/docs/types/test.ts index 6306c6ca4896..31f54d45c85e 100644 --- a/lib/node_modules/@stdlib/array/convert/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/convert/docs/types/test.ts @@ -25,6 +25,7 @@ import convert = require( './index' ); { convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float64' ); // $ExpectType Float64Array convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float32' ); // $ExpectType Float32Array + convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float16' ); // $ExpectType Float16ArrayFallback convert( [ 1.0, 2.0, 3.0, 4.0 ], 'int32' ); // $ExpectType Int32Array convert( [ 1.0, 2.0, 3.0, 4.0 ], 'int16' ); // $ExpectType Int16Array convert( [ 1.0, 2.0, 3.0, 4.0 ], 'int8' ); // $ExpectType Int8Array diff --git a/lib/node_modules/@stdlib/array/convert/test/test.js b/lib/node_modules/@stdlib/array/convert/test/test.js index e955d4ddb5e6..21500b10e695 100644 --- a/lib/node_modules/@stdlib/array/convert/test/test.js +++ b/lib/node_modules/@stdlib/array/convert/test/test.js @@ -25,6 +25,7 @@ var tape = require( 'tape' ); var Float64Array = require( '@stdlib/array/float64' ); var Float32Array = require( '@stdlib/array/float32' ); +var Float16Array = require( '@stdlib/array/float16' ); var Int16Array = require( '@stdlib/array/int16' ); var Int32Array = require( '@stdlib/array/int32' ); var Int8Array = require( '@stdlib/array/int8' ); @@ -38,6 +39,7 @@ var BooleanArray = require( '@stdlib/array/bool' ); var isArray = require( '@stdlib/assert/is-array' ); var isFloat64Array = require( '@stdlib/assert/is-float64array' ); var isFloat32Array = require( '@stdlib/assert/is-float32array' ); +var isFloat16Array = require( '@stdlib/assert/is-float16array' ); var isInt16Array = require( '@stdlib/assert/is-int16array' ); var isInt32Array = require( '@stdlib/assert/is-int32array' ); var isInt8Array = require( '@stdlib/assert/is-int8array' ); @@ -136,6 +138,7 @@ tape( 'the function converts an array to an array of a different data type', fun dtypes = [ 'float64', 'float32', + 'float16', 'generic', 'int16', 'int32', @@ -149,6 +152,7 @@ tape( 'the function converts an array to an array of a different data type', fun expected = [ [ new Float64Array( [ -1.0, 0.0, 1.0 ] ), isFloat64Array ], [ new Float32Array( [ -1.0, 0.0, 1.0 ] ), isFloat32Array ], + [ new Float16Array( [ -1.0, 0.0, 1.0 ] ), isFloat16Array ], [ arr, isArray ], [ new Int16Array( [ -1, 0, 1 ] ), isInt16Array ], [ new Int32Array( [ -1, 0, 1 ] ), isInt32Array ], @@ -179,6 +183,7 @@ tape( 'the function converts an array to an array of a different data type (acce dtypes = [ 'float64', 'float32', + 'float16', 'generic', 'int16', 'int32', @@ -197,6 +202,7 @@ tape( 'the function converts an array to an array of a different data type (acce expected = [ [ new Float64Array( [ -1.0, 0.0, 1.0 ] ), isFloat64Array ], [ new Float32Array( [ -1.0, 0.0, 1.0 ] ), isFloat32Array ], + [ new Float16Array( [ -1.0, 0.0, 1.0 ] ), isFloat16Array ], [ [ -1, 0, 1 ], isArray ], [ new Int16Array( [ -1, 0, 1 ] ), isInt16Array ], [ new Int32Array( [ -1, 0, 1 ] ), isInt32Array ], @@ -461,6 +467,7 @@ tape( 'the function converts an array to an array of a different data type (comp dtypes = [ 'float64', 'float32', + 'float16', 'int16', 'int32', 'int8', @@ -473,6 +480,7 @@ tape( 'the function converts an array to an array of a different data type (comp expected = [ [ new Float64Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat64Array ], [ new Float32Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat32Array ], + [ new Float16Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat16Array ], [ new Int16Array( [ -1, 0, 1, 2 ] ), isInt16Array ], [ new Int32Array( [ -1, 0, 1, 2 ] ), isInt32Array ], [ new Int8Array( [ -1, 0, 1, 2 ] ), isInt8Array ], @@ -502,6 +510,7 @@ tape( 'the function converts an array to an array of a different data type (comp dtypes = [ 'float64', 'float32', + 'float16', 'int16', 'int32', 'int8', @@ -514,6 +523,7 @@ tape( 'the function converts an array to an array of a different data type (comp expected = [ [ new Float64Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat64Array ], [ new Float32Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat32Array ], + [ new Float16Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat16Array ], [ new Int16Array( [ -1, 0, 1, 2 ] ), isInt16Array ], [ new Int32Array( [ -1, 0, 1, 2 ] ), isInt32Array ], [ new Int8Array( [ -1, 0, 1, 2 ] ), isInt8Array ], @@ -543,6 +553,7 @@ tape( 'the function converts an array to an array of a different data type (bool dtypes = [ 'float64', 'float32', + 'float16', 'int16', 'int32', 'int8', @@ -555,6 +566,7 @@ tape( 'the function converts an array to an array of a different data type (bool expected = [ [ new Float64Array( [ 1.0, 0.0, 1.0 ] ), isFloat64Array ], [ new Float32Array( [ 1.0, 0.0, 1.0 ] ), isFloat32Array ], + [ new Float16Array( [ 1.0, 0.0, 1.0 ] ), isFloat16Array ], [ new Int16Array( [ 1, 0, 1 ] ), isInt16Array ], [ new Int32Array( [ 1, 0, 1 ] ), isInt32Array ], [ new Int8Array( [ 1, 0, 1 ] ), isInt8Array ], @@ -673,6 +685,7 @@ tape( 'the function converts an array to an array of a different data type (larg dtypes = [ 'float64', 'float32', + 'float16', 'generic', 'int16', 'int32', @@ -692,6 +705,7 @@ tape( 'the function converts an array to an array of a different data type (larg expected = [ isFloat64Array, isFloat32Array, + isFloat16Array, isArray, isInt16Array, isInt32Array, From 6187a59c7936f20181c871f0bd272e307a3f177d Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Mon, 10 Aug 2026 14:05:30 +0530 Subject: [PATCH 2/2] fix: simplify loop for dtype iteration in benchmark --- 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: na - task: lint_javascript_benchmarks status: na - task: lint_python status: missing_dependencies - 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/convert/benchmark/python/numpy/benchmark.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/array/convert/benchmark/python/numpy/benchmark.py b/lib/node_modules/@stdlib/array/convert/benchmark/python/numpy/benchmark.py index abb86e5f6305..850c6402f743 100755 --- a/lib/node_modules/@stdlib/array/convert/benchmark/python/numpy/benchmark.py +++ b/lib/node_modules/@stdlib/array/convert/benchmark/python/numpy/benchmark.py @@ -121,8 +121,7 @@ def main(): n = 1 while n < 1e7: n *= 10 - for i in range(0, len(dtypes)): - dtype = dtypes[i] + for dtype in dtypes: name = ":len="+str(n)+",dtype="+dtype setup = "import numpy as np;" setup += "A = np.ones([1,"+str(n)+"], dtype='float64');"