From 119e117f9429578faae8a8b3c052cc2ae35b0598 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Tue, 1 Sep 2026 02:24:51 +0530 Subject: [PATCH] feat: add float16 dtype support to array/to-fancy --- 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: passed - task: lint_license_headers status: passed --- --- .../array/to-fancy/docs/types/index.d.ts | 11 ++ .../@stdlib/array/to-fancy/docs/types/test.ts | 3 + .../to-fancy/test/test.set.boolean_array.js | 137 +++++++++++++++ .../to-fancy/test/test.set.integer_array.js | 164 ++++++++++++++++++ .../to-fancy/test/test.set.mask_array.js | 137 +++++++++++++++ .../array/to-fancy/test/test.set.slice.js | 164 ++++++++++++++++++ .../to-fancy/test/test.set.subsequence.js | 98 +++++++++++ 7 files changed, 714 insertions(+) diff --git a/lib/node_modules/@stdlib/array/to-fancy/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/to-fancy/docs/types/index.d.ts index a20bc452d7d9..4f4caa53b9d2 100644 --- a/lib/node_modules/@stdlib/array/to-fancy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/to-fancy/docs/types/index.d.ts @@ -87,6 +87,17 @@ interface Array2Fancy { * // returns [ 1.0, 2.0, 3.0, 4.0 ] * * @example + * var Float16Array = require( '@stdlib/array/float16' ); + * + * var x = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * + * var y = array2fancy( x ); + * // returns + * + * var v = y[ ':' ]; + * // returns [ 1.0, 2.0, 3.0, 4.0 ] + * + * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); diff --git a/lib/node_modules/@stdlib/array/to-fancy/docs/types/test.ts b/lib/node_modules/@stdlib/array/to-fancy/docs/types/test.ts index 43b724ce5840..81eecf8f393f 100644 --- a/lib/node_modules/@stdlib/array/to-fancy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/to-fancy/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import Float16Array = require( '@stdlib/array/float16' ); import Complex128Array = require( '@stdlib/array/complex128' ); import Complex64Array = require( '@stdlib/array/complex64' ); import BooleanArray = require( '@stdlib/array/bool' ); @@ -29,6 +30,7 @@ import array2fancy = require( './index' ); array2fancy( [ 1, 2, 3 ] ); // $ExpectType number[] array2fancy( new Float64Array( [ 1, 2, 3 ] ) ); // $ExpectType Float64Array array2fancy( new Float32Array( [ 1, 2, 3 ] ) ); // $ExpectType Float32Array + array2fancy( new Float16Array( [ 1, 2, 3 ] ) ); // $ExpectType Float16Array array2fancy( new Int32Array( [ 1, 2, 3 ] ) ); // $ExpectType Int32Array array2fancy( new Int16Array( [ 1, 2, 3 ] ) ); // $ExpectType Int16Array array2fancy( new Int8Array( [ 1, 2, 3 ] ) ); // $ExpectType Int8Array @@ -46,6 +48,7 @@ import array2fancy = require( './index' ); array2fancy( [ 1, 2, 3 ], opts ); // $ExpectType number[] array2fancy( new Float64Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Float64Array array2fancy( new Float32Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Float32Array + array2fancy( new Float16Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Float16Array array2fancy( new Int32Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Int32Array array2fancy( new Int16Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Int16Array array2fancy( new Int8Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Int8Array diff --git a/lib/node_modules/@stdlib/array/to-fancy/test/test.set.boolean_array.js b/lib/node_modules/@stdlib/array/to-fancy/test/test.set.boolean_array.js index c351aad41ce4..2d74bee23d2a 100644 --- a/lib/node_modules/@stdlib/array/to-fancy/test/test.set.boolean_array.js +++ b/lib/node_modules/@stdlib/array/to-fancy/test/test.set.boolean_array.js @@ -24,9 +24,11 @@ var tape = require( 'tape' ); var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat16Array = require( '@stdlib/assert/is-same-float16array' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var Float32Array = require( '@stdlib/array/float32' ); +var Float16Array = require( '@stdlib/array/float16' ); var Int32Array = require( '@stdlib/array/int32' ); var Int8Array = require( '@stdlib/array/int8' ); var Uint32Array = require( '@stdlib/array/uint32' ); @@ -278,6 +280,51 @@ tape( 'the function returns an array-like object supporting boolean array assign t.end(); }); +tape( 'the function returns an array-like object supporting boolean array assignment (float16)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ true, true, true, true ] ); + expected = new Float16Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float16Array( [ 5, 6, 7, 8 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); + expected = new Float16Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ false, true, true, false ] ); + expected = new Float16Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); + expected = new Float16Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting boolean array assignment (complex128)', opts, function test( t ) { var expected; var idx; @@ -917,6 +964,51 @@ tape( 'the function returns an array-like object supporting casting (float64, fl t.end(); }); +tape( 'the function returns an array-like object supporting casting (float64, float16)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ true, true, true, true ] ); + expected = new Float64Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float16Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); + expected = new Float64Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ false, true, true, false ] ); + expected = new Float64Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); + expected = new Float64Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting casting (int32, int8)', opts, function test( t ) { var expected; var idx; @@ -1142,6 +1234,51 @@ tape( 'the function returns an array-like object supporting downcasting of float t.end(); }); +tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (float16, float64)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ true, true, true, true ] ); + expected = new Float16Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); + expected = new Float16Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ false, true, true, false ] ); + expected = new Float16Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); + expected = new Float16Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (complex64, complex128)', opts, function test( t ) { var expected; var idx; diff --git a/lib/node_modules/@stdlib/array/to-fancy/test/test.set.integer_array.js b/lib/node_modules/@stdlib/array/to-fancy/test/test.set.integer_array.js index 49ef2407eaf8..172a89e17a18 100644 --- a/lib/node_modules/@stdlib/array/to-fancy/test/test.set.integer_array.js +++ b/lib/node_modules/@stdlib/array/to-fancy/test/test.set.integer_array.js @@ -24,9 +24,11 @@ var tape = require( 'tape' ); var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat16Array = require( '@stdlib/assert/is-same-float16array' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var Float32Array = require( '@stdlib/array/float32' ); +var Float16Array = require( '@stdlib/array/float16' ); var Int32Array = require( '@stdlib/array/int32' ); var Int8Array = require( '@stdlib/array/int8' ); var Uint32Array = require( '@stdlib/array/uint32' ); @@ -322,6 +324,60 @@ tape( 'the function returns an array-like object supporting integer array assign t.end(); }); +tape( 'the function returns an array-like object supporting integer array assignment (float16)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Float16Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float16Array( [ 5, 6, 7, 8 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); + expected = new Float16Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Float16Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); + expected = new Float16Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Float16Array( [ 1, 6, 3, 5 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting integer array assignment (complex128)', opts, function test( t ) { var expected; var idx; @@ -1078,6 +1134,60 @@ tape( 'the function returns an array-like object supporting casting (float64, fl t.end(); }); +tape( 'the function returns an array-like object supporting casting (float64, float16)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Float64Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float16Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); + expected = new Float64Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Float64Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); + expected = new Float64Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Float64Array( [ 1, 6, 3, 5 ] ); + y[ idx ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting casting (int32, int8)', opts, function test( t ) { var expected; var idx; @@ -1348,6 +1458,60 @@ tape( 'the function returns an array-like object supporting downcasting of float t.end(); }); +tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (float16, float64)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); + expected = new Float16Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); + expected = new Float16Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ 1, 2 ] ); + expected = new Float16Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); + expected = new Float16Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( [ -1, -3 ] ); + expected = new Float16Array( [ 1, 6, 3, 5 ] ); + y[ idx ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (complex64, complex128)', opts, function test( t ) { var expected; var idx; diff --git a/lib/node_modules/@stdlib/array/to-fancy/test/test.set.mask_array.js b/lib/node_modules/@stdlib/array/to-fancy/test/test.set.mask_array.js index 99fc46295147..c85c0df6854f 100644 --- a/lib/node_modules/@stdlib/array/to-fancy/test/test.set.mask_array.js +++ b/lib/node_modules/@stdlib/array/to-fancy/test/test.set.mask_array.js @@ -24,9 +24,11 @@ var tape = require( 'tape' ); var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat16Array = require( '@stdlib/assert/is-same-float16array' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var Float32Array = require( '@stdlib/array/float32' ); +var Float16Array = require( '@stdlib/array/float16' ); var Int32Array = require( '@stdlib/array/int32' ); var Int8Array = require( '@stdlib/array/int8' ); var Uint32Array = require( '@stdlib/array/uint32' ); @@ -278,6 +280,51 @@ tape( 'the function returns an array-like object supporting mask array assignmen t.end(); }); +tape( 'the function returns an array-like object supporting mask array assignment (float16)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); + expected = new Float16Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float16Array( [ 5, 6, 7, 8 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); + expected = new Float16Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6, 0, 0 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); + expected = new Float16Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 0, 5, 6, 0 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); + expected = new Float16Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 0, 6, 0 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting mask array assignment (complex128)', opts, function test( t ) { var expected; var idx; @@ -917,6 +964,51 @@ tape( 'the function returns an array-like object supporting casting (float64, fl t.end(); }); +tape( 'the function returns an array-like object supporting casting (float64, float16)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); + expected = new Float64Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float16Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); + expected = new Float64Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 6, 0, 0 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); + expected = new Float64Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 0, 5, 6, 0 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); + expected = new Float64Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float16Array( [ 5, 0, 6, 0 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting casting (int32, int8)', opts, function test( t ) { var expected; var idx; @@ -1142,6 +1234,51 @@ tape( 'the function returns an array-like object supporting downcasting of float t.end(); }); +tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (float16, float64)', opts, function test( t ) { + var expected; + var idx; + var x; + var y; + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); + expected = new Float16Array( [ 5, 6, 7, 8 ] ); + y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); + expected = new Float16Array( [ 5, 6, 3, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 6, 0, 0 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); + expected = new Float16Array( [ 1, 5, 6, 4 ] ); + y[ idx ] = new Float64Array( [ 0, 5, 6, 0 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); + expected = new Float16Array( [ 5, 2, 6, 4 ] ); + y[ idx ] = new Float64Array( [ 5, 0, 6, 0 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (complex64, complex128)', opts, function test( t ) { var expected; var idx; diff --git a/lib/node_modules/@stdlib/array/to-fancy/test/test.set.slice.js b/lib/node_modules/@stdlib/array/to-fancy/test/test.set.slice.js index 217bdb5b7f22..d6f36b06cffe 100644 --- a/lib/node_modules/@stdlib/array/to-fancy/test/test.set.slice.js +++ b/lib/node_modules/@stdlib/array/to-fancy/test/test.set.slice.js @@ -24,10 +24,12 @@ var tape = require( 'tape' ); var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat16Array = require( '@stdlib/assert/is-same-float16array' ); var Slice = require( '@stdlib/slice/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var Float32Array = require( '@stdlib/array/float32' ); +var Float16Array = require( '@stdlib/array/float16' ); var Int32Array = require( '@stdlib/array/int32' ); var Int8Array = require( '@stdlib/array/int8' ); var Uint32Array = require( '@stdlib/array/uint32' ); @@ -323,6 +325,60 @@ tape( 'the function returns an array-like object supporting slice assignment (fl t.end(); }); +tape( 'the function returns an array-like object supporting slice assignment (float16)', opts, function test( t ) { + var expected; + var x; + var y; + var s; + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice(); + expected = new Float16Array( [ 5, 6, 7, 8 ] ); + y[ s ] = new Float16Array( [ 5, 6, 7, 8 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( 2 ); + expected = new Float16Array( [ 5, 6, 3, 4 ] ); + y[ s ] = new Float16Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( 1, 3 ); + expected = new Float16Array( [ 1, 5, 6, 4 ] ); + y[ s ] = new Float16Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( null, null, 2 ); + expected = new Float16Array( [ 5, 2, 6, 4 ] ); + y[ s ] = new Float16Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( -1, null, -2 ); + expected = new Float16Array( [ 1, 6, 3, 5 ] ); + y[ s ] = new Float16Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting slice assignment (complex128)', opts, function test( t ) { var expected; var x; @@ -1079,6 +1135,60 @@ tape( 'the function returns an array-like object supporting casting (float64, fl t.end(); }); +tape( 'the function returns an array-like object supporting casting (float64, float16)', opts, function test( t ) { + var expected; + var x; + var y; + var s; + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice(); + expected = new Float64Array( [ 5, 6, 7, 8 ] ); + y[ s ] = new Float16Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( 2 ); + expected = new Float64Array( [ 5, 6, 3, 4 ] ); + y[ s ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( 1, 3 ); + expected = new Float64Array( [ 1, 5, 6, 4 ] ); + y[ s ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( null, null, 2 ); + expected = new Float64Array( [ 5, 2, 6, 4 ] ); + y[ s ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( -1, null, -2 ); + expected = new Float64Array( [ 1, 6, 3, 5 ] ); + y[ s ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting casting (int32, int8)', opts, function test( t ) { var expected; var x; @@ -1349,6 +1459,60 @@ tape( 'the function returns an array-like object supporting downcasting of float t.end(); }); +tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (float16, float64)', opts, function test( t ) { + var expected; + var x; + var y; + var s; + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice(); + expected = new Float16Array( [ 5, 6, 7, 8 ] ); + y[ s ] = new Float64Array( [ 5, 6, 7, 8 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( 2 ); + expected = new Float16Array( [ 5, 6, 3, 4 ] ); + y[ s ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( 1, 3 ); + expected = new Float16Array( [ 1, 5, 6, 4 ] ); + y[ s ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( null, null, 2 ); + expected = new Float16Array( [ 5, 2, 6, 4 ] ); + y[ s ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + s = new Slice( -1, null, -2 ); + expected = new Float16Array( [ 1, 6, 3, 5 ] ); + y[ s ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (complex64, complex128)', opts, function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/array/to-fancy/test/test.set.subsequence.js b/lib/node_modules/@stdlib/array/to-fancy/test/test.set.subsequence.js index 38580b7b57b1..a1279244b9b8 100644 --- a/lib/node_modules/@stdlib/array/to-fancy/test/test.set.subsequence.js +++ b/lib/node_modules/@stdlib/array/to-fancy/test/test.set.subsequence.js @@ -24,9 +24,11 @@ var tape = require( 'tape' ); var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var isSameFloat16Array = require( '@stdlib/assert/is-same-float16array' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var Float32Array = require( '@stdlib/array/float32' ); +var Float16Array = require( '@stdlib/array/float16' ); var Int32Array = require( '@stdlib/array/int32' ); var Int8Array = require( '@stdlib/array/int8' ); var Uint32Array = require( '@stdlib/array/uint32' ); @@ -964,6 +966,54 @@ tape( 'the function returns an array-like object supporting casting (float64, fl t.end(); }); +tape( 'the function returns an array-like object supporting casting (float64, float16)', opts, function test( t ) { + var expected; + var x; + var y; + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + expected = new Float64Array( [ 5, 6, 7, 8 ] ); + y[ ':' ] = new Float16Array( [ 5, 6, 7, 8 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + expected = new Float64Array( [ 5, 6, 3, 4 ] ); + y[ ':2' ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + expected = new Float64Array( [ 1, 5, 6, 4 ] ); + y[ '1:3' ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + expected = new Float64Array( [ 5, 2, 6, 4 ] ); + y[ '::2' ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + x = new Float64Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + expected = new Float64Array( [ 1, 6, 3, 5 ] ); + y[ '-1::-2' ] = new Float16Array( [ 5, 6 ] ); + + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting casting (int32, int8)', opts, function test( t ) { var expected; var x; @@ -1204,6 +1254,54 @@ tape( 'the function returns an array-like object supporting downcasting of float t.end(); }); +tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (float16, float64)', opts, function test( t ) { + var expected; + var x; + var y; + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + expected = new Float16Array( [ 5, 6, 7, 8 ] ); + y[ ':' ] = new Float64Array( [ 5, 6, 7, 8 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + expected = new Float16Array( [ 5, 6, 3, 4 ] ); + y[ ':2' ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + expected = new Float16Array( [ 1, 5, 6, 4 ] ); + y[ '1:3' ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + expected = new Float16Array( [ 5, 2, 6, 4 ] ); + y[ '::2' ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + x = new Float16Array( [ 1, 2, 3, 4 ] ); + y = array2fancy( x ); + + expected = new Float16Array( [ 1, 6, 3, 5 ] ); + y[ '-1::-2' ] = new Float64Array( [ 5, 6 ] ); + + t.strictEqual( isSameFloat16Array( y, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (complex64, complex128)', opts, function test( t ) { var expected; var x;