From 5e5b4daafa33abac62e09db77beb1214a5a64be6 Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Tue, 25 Aug 2026 01:47:27 +0530 Subject: [PATCH 1/5] feat: add float16 dtype support to array/linspace --- .../benchmark.assign.float16_real.length.js | 96 +++++++++++++ .../benchmark.float16_real.length.js | 99 +++++++++++++ .../array/linspace/benchmark/benchmark.js | 24 ++++ .../array/linspace/docs/types/index.d.ts | 51 ++++++- .../@stdlib/array/linspace/docs/types/test.ts | 4 + .../@stdlib/array/linspace/package.json | 6 +- .../@stdlib/array/linspace/test/test.main.js | 133 ++++++++++++++++++ 7 files changed, 411 insertions(+), 2 deletions(-) create mode 100644 lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.assign.float16_real.length.js create mode 100644 lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.float16_real.length.js diff --git a/lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.assign.float16_real.length.js b/lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.assign.float16_real.length.js new file mode 100644 index 000000000000..cf5fdddf4fb3 --- /dev/null +++ b/lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.assign.float16_real.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 pow = require( '@stdlib/math/base/special/pow' ); +var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); +var Float16Array = require( '@stdlib/array/float16' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var linspace = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var out = new Float16Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = linspace.assign( 0.0, 100.0, out ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array-like object' ); + } + } + b.toc(); + if ( !isArrayLikeObject( v ) ) { + b.fail( 'should return an array-like object' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s::real:assign:dtype=float16,len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.float16_real.length.js b/lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.float16_real.length.js new file mode 100644 index 000000000000..b1c79656d755 --- /dev/null +++ b/lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.float16_real.length.js @@ -0,0 +1,99 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 pow = require( '@stdlib/math/base/special/pow' ); +var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var linspace = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var opts; + var v; + var i; + + opts = { + 'dtype': 'float16' + }; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = linspace( 0.0, 100.0, len, opts ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array-like object' ); + } + } + b.toc(); + if ( !isArrayLikeObject( v ) ) { + b.fail( 'should return an array-like object' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s::real:dtype=float16,len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.js b/lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.js index e9bde16f0701..9a53051fc1df 100644 --- a/lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/array/linspace/benchmark/benchmark.js @@ -122,6 +122,30 @@ bench( format( '%s::real:dtype=float32', pkg ), function benchmark( b ) { b.end(); }); +bench( format( '%s::real:dtype=float16', pkg ), function benchmark( b ) { + var opts; + var v; + var i; + + opts = { + 'dtype': 'float16' + }; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = linspace( 0.0, 100.0, 10, opts ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an array-like object' ); + } + } + b.toc(); + if ( !isArrayLikeObject( v ) ) { + b.fail( 'should return an array-like object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + bench( format( '%s::real:dtype=generic', pkg ), function benchmark( b ) { var opts; var v; diff --git a/lib/node_modules/@stdlib/array/linspace/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/linspace/docs/types/index.d.ts index 43d95fd43421..2ccfb99c14c4 100644 --- a/lib/node_modules/@stdlib/array/linspace/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/linspace/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { FloatingPointDataType as DataType, ArrayLike, FloatOrComplexTypedArray, Complex64Array, Complex128Array } from '@stdlib/types/array'; +import { FloatingPointDataType as DataType, ArrayLike, FloatOrComplexTypedArray, Float16Array, Complex64Array, Complex128Array } from '@stdlib/types/array'; import { ComplexLike, Complex64, Complex128 } from '@stdlib/types/complex'; /** @@ -72,6 +72,16 @@ interface Float32Options extends BaseOptions { dtype: 'float32'; } +/** +* Interface describing function options. +*/ +interface Float16Options extends BaseOptions { + /** + * Output array data type. + */ + dtype: 'float16'; +} + /** * Interface describing function options. */ @@ -150,6 +160,26 @@ interface Linspace { */ ( start: number, stop: number, len: number, options: Float32Options ): Float32Array; + /** + * Generates a linearly spaced array over a specified interval. + * + * @param start - start of interval + * @param stop - end of interval + * @param len - length of output array + * @param options - function options + * @param options.dtype - output array data type + * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array + * @returns linearly spaced array + * + * @example + * var opts = { + * 'dtype': 'float16' + * }; + * var arr = linspace( 0.0, 100.0, 6, opts ); + * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] + */ + ( start: number, stop: number, len: number, options: Float16Options ): Float16Array; + /** * Generates a linearly spaced array over a specified interval. * @@ -450,6 +480,25 @@ interface Linspace { */ assign( start: number, stop: number, out: Float32Array, options?: BaseOptions ): Float32Array; + /** + * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. + * + * @param start - start of interval + * @param stop - end of interval + * @param out - output array + * @param options - function options + * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array + * @returns output array + * + * @example + * var Float16Array = require( '@stdlib/array/float16' ); + * + * var out = new Float16Array( 6 ); + * var arr = linspace.assign( 0.0, 100.0, out ); + * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] + */ + assign( start: number, stop: number, out: Float16Array, options?: BaseOptions ): Float16Array; + /** * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. * diff --git a/lib/node_modules/@stdlib/array/linspace/docs/types/test.ts b/lib/node_modules/@stdlib/array/linspace/docs/types/test.ts index 893207636cea..b12c70c7349b 100644 --- a/lib/node_modules/@stdlib/array/linspace/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/linspace/docs/types/test.ts @@ -20,6 +20,7 @@ import Complex64 = require( '@stdlib/complex/float32/ctor' ); import Complex128 = require( '@stdlib/complex/float64/ctor' ); import Complex128Array = require( '@stdlib/array/complex128' ); import Complex64Array = require( '@stdlib/array/complex64' ); +import Float16Array = require( '@stdlib/array/float16' ); import linspace = require( './index' ); @@ -34,6 +35,7 @@ import linspace = require( './index' ); linspace( 0, 11, 20, { 'dtype': 'float64' } ); // $ExpectType Float64Array linspace( 0, 11, 20, { 'dtype': 'float32' } ); // $ExpectType Float32Array + linspace( 0, 11, 20, { 'dtype': 'float16' } ); // $ExpectType Float16Array linspace( 0, 11, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array linspace( 0, 11, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array linspace( 0, 11, 20, { 'dtype': 'generic' } ); // $ExpectType number[] @@ -216,6 +218,7 @@ import linspace = require( './index' ); const o3 = [ 1, 2, 3, 4 ]; const o4 = new Complex128Array( 10 ); const o5 = new Complex64Array( 10 ); + const o6 = new Float16Array( 10 ); linspace.assign( 0, 11, o1 ); // $ExpectType Float64Array @@ -223,6 +226,7 @@ import linspace = require( './index' ); linspace.assign( 0, 11, o1, { 'endpoint': false } ); // $ExpectType Float64Array linspace.assign( 0, 11, o2 ); // $ExpectType Float32Array + linspace.assign( 0, 11, o6 ); // $ExpectType Float16Array linspace.assign( 0, 11, o3 ); // $ExpectType number[] linspace.assign( 0, 11, o4 ); // $ExpectType Complex128Array linspace.assign( 0, 11, o5 ); // $ExpectType Complex64Array diff --git a/lib/node_modules/@stdlib/array/linspace/package.json b/lib/node_modules/@stdlib/array/linspace/package.json index 89f3d9f6c431..f79b69641503 100644 --- a/lib/node_modules/@stdlib/array/linspace/package.json +++ b/lib/node_modules/@stdlib/array/linspace/package.json @@ -57,8 +57,12 @@ "math", "generic", "array", + "float16array", "matlab", "linear", - "linspace" + "linspace", + "half", + "half-precision", + "float16" ] } diff --git a/lib/node_modules/@stdlib/array/linspace/test/test.main.js b/lib/node_modules/@stdlib/array/linspace/test/test.main.js index 343f3a60935f..e54a9f72f944 100644 --- a/lib/node_modules/@stdlib/array/linspace/test/test.main.js +++ b/lib/node_modules/@stdlib/array/linspace/test/test.main.js @@ -27,10 +27,12 @@ var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var Float32Array = require( '@stdlib/array/float32' ); +var Float16Array = require( '@stdlib/array/float16' ); var isComplex128 = require( '@stdlib/assert/is-complex128' ); var isComplex64 = require( '@stdlib/assert/is-complex64' ); var isFloat64Array = require( '@stdlib/assert/is-float64array' ); var isFloat32Array = require( '@stdlib/assert/is-float32array' ); +var isFloat16Array = require( '@stdlib/assert/is-float16array' ); var isArray = require( '@stdlib/assert/is-array' ); var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); @@ -482,6 +484,24 @@ tape( 'if the specified output array length is `0`, the function returns an empt t.end(); }); +tape( 'if the specified output array length is `0`, the function returns an empty array (dtype=float16)', function test( t ) { + var expected; + var actual; + var opts; + + opts = { + 'dtype': 'float16', + 'endpoint': true + }; + actual = linspace( 0, 10, 0, opts ); + expected = new Float16Array( [] ); + + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if the specified output array length is `0`, the function returns an empty array (dtype=complex128)', function test( t ) { var expected; var actual; @@ -689,6 +709,23 @@ tape( 'if the specified output array length is `1`, the function returns an arra t.end(); }); +tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float16)', function test( t ) { + var expected; + var actual; + var opts; + + opts = { + 'dtype': 'float16' + }; + actual = linspace( 0, 10, 1, opts ); + expected = new Float16Array( [ 10.0 ] ); + + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128)', function test( t ) { var expected; var actual; @@ -1022,6 +1059,25 @@ tape( 'if the specified output array length is `1`, the function returns an arra t.end(); }); +tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float16; endpoint=true)', function test( t ) { + var expected; + var actual; + var opts; + + opts = { + 'dtype': 'float16', + 'endpoint': true + }; + actual = linspace( 0, 10, 1, opts ); + expected = new Float16Array( [ 10.0 ] ); + + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=true)', function test( t ) { var expected; var actual; @@ -1366,6 +1422,24 @@ tape( 'if the specified output array length is `1`, the function returns an arra t.end(); }); +tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float16; endpoint=false)', function test( t ) { + var expected; + var actual; + var opts; + + opts = { + 'dtype': 'float16', + 'endpoint': false + }; + actual = linspace( 0, 10, 1, opts ); + expected = new Float16Array( [ 0.0 ] ); + + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=false)', function test( t ) { var expected; var actual; @@ -1782,6 +1856,65 @@ tape( 'the function returns a linearly spaced array (real; dtype=float32)', func t.end(); }); +tape( 'the function returns a linearly spaced array (real; dtype=float16)', function test( t ) { + var expected; + var actual; + var opts; + var x1; + var x2; + + x1 = -5.0; + x2 = 5.0; + + opts = { + 'dtype': 'float16' + }; + + actual = linspace( x1, x2, 2, opts ); + expected = new Float16Array( [ x1, x2 ] ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 2, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + actual = linspace( x2, x1, 2, opts ); + expected = new Float16Array( [ x2, x1 ] ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 2, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + actual = linspace( x1, x2, 6, opts ); + expected = new Float16Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 6, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + actual = linspace( x2, x1, 6, opts ); + expected = new Float16Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 6, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + actual = linspace( x2, x2, 6, opts ); + expected = new Float16Array( [ x2, x2, x2, x2, x2, x2 ] ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 6, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + actual = linspace( x1, x2, 5, opts ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 5, 'returns expected value' ); + t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); + t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); + + actual = linspace( x2, x1, 5, opts ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 5, 'returns expected value' ); + t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); + t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a linearly spaced array (real; dtype=generic)', function test( t ) { var expected; var actual; From febc9d43fd6337d3d458a700eb59355fec59b21d Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Tue, 25 Aug 2026 19:51:51 +0530 Subject: [PATCH 2/5] docs: update Float16Array ExpectType assertion to Float16ArrayFallback in array/linspace --- lib/node_modules/@stdlib/array/linspace/docs/types/test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/array/linspace/docs/types/test.ts b/lib/node_modules/@stdlib/array/linspace/docs/types/test.ts index b12c70c7349b..ae909027d8d2 100644 --- a/lib/node_modules/@stdlib/array/linspace/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/linspace/docs/types/test.ts @@ -35,7 +35,7 @@ import linspace = require( './index' ); linspace( 0, 11, 20, { 'dtype': 'float64' } ); // $ExpectType Float64Array linspace( 0, 11, 20, { 'dtype': 'float32' } ); // $ExpectType Float32Array - linspace( 0, 11, 20, { 'dtype': 'float16' } ); // $ExpectType Float16Array + linspace( 0, 11, 20, { 'dtype': 'float16' } ); // $ExpectType Float16ArrayFallback linspace( 0, 11, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array linspace( 0, 11, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array linspace( 0, 11, 20, { 'dtype': 'generic' } ); // $ExpectType number[] @@ -226,7 +226,7 @@ import linspace = require( './index' ); linspace.assign( 0, 11, o1, { 'endpoint': false } ); // $ExpectType Float64Array linspace.assign( 0, 11, o2 ); // $ExpectType Float32Array - linspace.assign( 0, 11, o6 ); // $ExpectType Float16Array + linspace.assign( 0, 11, o6 ); // $ExpectType Float16ArrayFallback linspace.assign( 0, 11, o3 ); // $ExpectType number[] linspace.assign( 0, 11, o4 ); // $ExpectType Complex128Array linspace.assign( 0, 11, o5 ); // $ExpectType Complex64Array From 7aefc6a66fc84eb78c44351b625302d04a5106e9 Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Wed, 26 Aug 2026 02:32:37 +0530 Subject: [PATCH 3/5] test: add Float16Array tests to assign method in array/linspace --- .../array/linspace/test/test.assign.js | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/lib/node_modules/@stdlib/array/linspace/test/test.assign.js b/lib/node_modules/@stdlib/array/linspace/test/test.assign.js index 93ccff81daca..0d848a2b1f5a 100644 --- a/lib/node_modules/@stdlib/array/linspace/test/test.assign.js +++ b/lib/node_modules/@stdlib/array/linspace/test/test.assign.js @@ -27,12 +27,14 @@ var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var Float32Array = require( '@stdlib/array/float32' ); +var Float16Array = require( '@stdlib/array/float16' ); var Complex128Array = require( '@stdlib/array/complex128' ); var Complex64Array = require( '@stdlib/array/complex64' ); var isComplex128 = require( '@stdlib/assert/is-complex128' ); var isComplex64 = require( '@stdlib/assert/is-complex64' ); var isFloat64Array = require( '@stdlib/assert/is-float64array' ); var isFloat32Array = require( '@stdlib/assert/is-float32array' ); +var isFloat16Array = require( '@stdlib/assert/is-float16array' ); var isArray = require( '@stdlib/assert/is-array' ); var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); @@ -376,6 +378,22 @@ tape( 'if the specified output array length is `0`, the function returns the out t.end(); }); +tape( 'if the specified output array length is `0`, the function returns the output array unchanged (dtype=float16)', function test( t ) { + var expected; + var actual; + var out; + + out = new Float16Array( 0 ); + actual = linspace( 0, 10, out ); + expected = new Float16Array( out.length ); + + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual, out, 'returns expected value' ); + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + + t.end(); +}); + tape( 'if the specified output array length is `0`, the function returns the output array unchanged (dtype=complex128)', function test( t ) { var expected; var actual; @@ -493,6 +511,22 @@ tape( 'if the specified output array length is `1`, the function returns an arra t.end(); }); +tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float16)', function test( t ) { + var expected; + var actual; + var out; + + out = new Float16Array( 1 ); + actual = linspace( 0, 10, out ); + expected = new Float16Array( [ 10.0 ] ); + + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual, out, 'returns expected value' ); + t.strictEqual( actual[ 0 ], expected[ 0 ], 'returns expected value' ); + + t.end(); +}); + tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128)', function test( t ) { var expected; var actual; @@ -1638,6 +1672,75 @@ tape( 'the function returns a linearly spaced array (real; dtype=float32)', func t.end(); }); +tape( 'the function returns a linearly spaced array (real; dtype=float16)', function test( t ) { + var expected; + var actual; + var out; + var x1; + var x2; + + x1 = -5.0; + x2 = 5.0; + + out = new Float16Array( 2 ); + actual = linspace( x1, x2, out ); + expected = new Float16Array( [ x1, x2 ] ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 2, 'returns expected value' ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + out = new Float16Array( 2 ); + actual = linspace( x2, x1, out ); + expected = new Float16Array( [ x2, x1 ] ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 2, 'returns expected value' ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + out = new Float16Array( 6 ); + actual = linspace( x1, x2, out ); + expected = new Float16Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 6, 'returns expected value' ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + out = new Float16Array( 6 ); + actual = linspace( x2, x1, out ); + expected = new Float16Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 6, 'returns expected value' ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + out = new Float16Array( 6 ); + actual = linspace( x2, x2, out ); + expected = new Float16Array( [ x2, x2, x2, x2, x2, x2 ] ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 6, 'returns expected value' ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + out = new Float16Array( 5 ); + actual = linspace( x1, x2, out ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 5, 'returns expected value' ); + t.strictEqual( actual, out, 'returns expected value' ); + t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); + t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); + + out = new Float16Array( 5 ); + actual = linspace( x2, x1, out ); + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual.length, 5, 'returns expected value' ); + t.strictEqual( actual, out, 'returns expected value' ); + t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); + t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a linearly spaced array (real; dtype=generic)', function test( t ) { var expected; var actual; From 05a72f4373da61779d2fa71242383cb7d12c274a Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Wed, 26 Aug 2026 03:02:08 +0530 Subject: [PATCH 4/5] test: add Float16Array tests to assign method in array/linspace --- .../array/linspace/test/test.assign.js | 50 +++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/array/linspace/test/test.assign.js b/lib/node_modules/@stdlib/array/linspace/test/test.assign.js index 0d848a2b1f5a..8fd65b456b16 100644 --- a/lib/node_modules/@stdlib/array/linspace/test/test.assign.js +++ b/lib/node_modules/@stdlib/array/linspace/test/test.assign.js @@ -381,15 +381,19 @@ tape( 'if the specified output array length is `0`, the function returns the out tape( 'if the specified output array length is `0`, the function returns the output array unchanged (dtype=float16)', function test( t ) { var expected; var actual; + var opts; var out; + opts = { + 'endpoint': true + }; out = new Float16Array( 0 ); - actual = linspace( 0, 10, out ); + actual = linspace( 0, 10, out, opts ); expected = new Float16Array( out.length ); t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); t.end(); }); @@ -522,7 +526,7 @@ tape( 'if the specified output array length is `1`, the function returns an arra t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], expected[ 0 ], 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); t.end(); }); @@ -813,6 +817,26 @@ tape( 'if the specified output array length is `1`, the function returns an arra t.end(); }); +tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float16; endpoint=true)', function test( t ) { + var expected; + var actual; + var opts; + var out; + + opts = { + 'endpoint': true + }; + out = new Float16Array( 1 ); + actual = linspace( 0, 10, out, opts ); + expected = new Float16Array( [ 10.0 ] ); + + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=true)', function test( t ) { var expected; var actual; @@ -1153,6 +1177,26 @@ tape( 'if the specified output array length is `1`, the function returns an arra t.end(); }); +tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float16; endpoint=false)', function test( t ) { + var expected; + var actual; + var opts; + var out; + + opts = { + 'endpoint': false + }; + out = new Float16Array( 1 ); + actual = linspace( 0, 10, out, opts ); + expected = new Float16Array( [ 0.0 ] ); + + t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=false)', function test( t ) { var expected; var actual; From d5079ee86ec373f67b44f1711cec120fe6c33852 Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Thu, 27 Aug 2026 11:08:22 +0530 Subject: [PATCH 5/5] fix(array/linspace): address PR review comments on keywords and test uniformity --- lib/node_modules/@stdlib/array/linspace/package.json | 6 +----- lib/node_modules/@stdlib/array/linspace/test/test.main.js | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/array/linspace/package.json b/lib/node_modules/@stdlib/array/linspace/package.json index f79b69641503..89f3d9f6c431 100644 --- a/lib/node_modules/@stdlib/array/linspace/package.json +++ b/lib/node_modules/@stdlib/array/linspace/package.json @@ -57,12 +57,8 @@ "math", "generic", "array", - "float16array", "matlab", "linear", - "linspace", - "half", - "half-precision", - "float16" + "linspace" ] } diff --git a/lib/node_modules/@stdlib/array/linspace/test/test.main.js b/lib/node_modules/@stdlib/array/linspace/test/test.main.js index e54a9f72f944..e0937fe05b08 100644 --- a/lib/node_modules/@stdlib/array/linspace/test/test.main.js +++ b/lib/node_modules/@stdlib/array/linspace/test/test.main.js @@ -1072,7 +1072,6 @@ tape( 'if the specified output array length is `1`, the function returns an arra expected = new Float16Array( [ 10.0 ] ); t.strictEqual( isFloat16Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); t.deepEqual( actual, expected, 'returns expected value' ); t.end();