Skip to content

Commit 860df0c

Browse files
committed
Auto-generated commit
1 parent 72e64ec commit 860df0c

7 files changed

Lines changed: 167 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Features
1212

13+
- [`123c0ed`](https://github.com/stdlib-js/stdlib/commit/123c0edfad02840cbe876c40338841990f426836) - add float16 dtype support to `ndarray/base/nans-like` [(#15449)](https://github.com/stdlib-js/stdlib/pull/15449)
1314
- [`91244cd`](https://github.com/stdlib-js/stdlib/commit/91244cd87e3d571a51ffd1de7a793ebcbec83147) - add float16 dtype support to `ndarray/base/full` [(#15429)](https://github.com/stdlib-js/stdlib/pull/15429)
1415
- [`2283ae0`](https://github.com/stdlib-js/stdlib/commit/2283ae09157f485a937f0aa62b91f3a56a112b9b) - add float16 dtype support to `ndarray/base/ones` [(#15432)](https://github.com/stdlib-js/stdlib/pull/15432)
1516
- [`19ba44c`](https://github.com/stdlib-js/stdlib/commit/19ba44c6719287a70a9127663ed554d1493c737b) - add float16 dtype support to `ndarray/base/full-by` [(#15433)](https://github.com/stdlib-js/stdlib/pull/15433)
@@ -121,6 +122,7 @@ A total of 4 issues were closed in this release:
121122

122123
<details>
123124

125+
- [`123c0ed`](https://github.com/stdlib-js/stdlib/commit/123c0edfad02840cbe876c40338841990f426836) - **feat:** add float16 dtype support to `ndarray/base/nans-like` [(#15449)](https://github.com/stdlib-js/stdlib/pull/15449) _(by Samarth Kolarkar)_
124126
- [`91244cd`](https://github.com/stdlib-js/stdlib/commit/91244cd87e3d571a51ffd1de7a793ebcbec83147) - **feat:** add float16 dtype support to `ndarray/base/full` [(#15429)](https://github.com/stdlib-js/stdlib/pull/15429) _(by Samarth Kolarkar)_
125127
- [`2283ae0`](https://github.com/stdlib-js/stdlib/commit/2283ae09157f485a937f0aa62b91f3a56a112b9b) - **feat:** add float16 dtype support to `ndarray/base/ones` [(#15432)](https://github.com/stdlib-js/stdlib/pull/15432) _(by Samarth Kolarkar)_
126128
- [`19ba44c`](https://github.com/stdlib-js/stdlib/commit/19ba44c6719287a70a9127663ed554d1493c737b) - **feat:** add float16 dtype support to `ndarray/base/full-by` [(#15433)](https://github.com/stdlib-js/stdlib/pull/15433) _(by Samarth Kolarkar)_

‎base/nans-like/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ var nansLike = require( '@stdlib/ndarray/base/nans-like' );
9191
var dt = [
9292
'float64',
9393
'float32',
94+
'float16',
9495
'complex128',
9596
'complex64',
9697
'generic'

‎base/nans-like/benchmark/benchmark.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,28 @@ bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) {
7474
b.end();
7575
});
7676

77+
bench( format( '%s:dtype=float16', pkg ), function benchmark( b ) {
78+
var x;
79+
var y;
80+
var i;
81+
82+
x = ones( 'float16', [ 0 ], 'row-major' );
83+
84+
b.tic();
85+
for ( i = 0; i < b.iterations; i++ ) {
86+
y = nansLike( x );
87+
if ( y.length !== 0 ) {
88+
b.fail( 'should have length 0' );
89+
}
90+
}
91+
b.toc();
92+
if ( !isndarrayLike( y ) ) {
93+
b.fail( 'should return an ndarray' );
94+
}
95+
b.pass( 'benchmark finished' );
96+
b.end();
97+
});
98+
7799
bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) {
78100
var x;
79101
var y;
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pow = require( '@stdlib/math/base/special/pow' );
25+
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
26+
var ones = require( './../../../base/ones' );
27+
var format = require( '@stdlib/string/format' );
28+
var pkg = require( './../package.json' ).name;
29+
var nansLike = require( './../lib' );
30+
31+
32+
// FUNCTIONS //
33+
34+
/**
35+
* Creates a benchmark function.
36+
*
37+
* @private
38+
* @param {PositiveInteger} len - array length
39+
* @returns {Function} benchmark function
40+
*/
41+
function createBenchmark( len ) {
42+
var x = ones( 'float16', [ len ], 'row-major' );
43+
return benchmark;
44+
45+
/**
46+
* Benchmark function.
47+
*
48+
* @private
49+
* @param {Benchmark} b - benchmark instance
50+
*/
51+
function benchmark( b ) {
52+
var arr;
53+
var i;
54+
55+
b.tic();
56+
for ( i = 0; i < b.iterations; i++ ) {
57+
arr = nansLike( x );
58+
if ( arr.length !== len ) {
59+
b.fail( 'unexpected length' );
60+
}
61+
}
62+
b.toc();
63+
if ( !isndarrayLike( arr ) ) {
64+
b.fail( 'should return an ndarray' );
65+
}
66+
b.pass( 'benchmark finished' );
67+
b.end();
68+
}
69+
}
70+
71+
72+
// MAIN //
73+
74+
/**
75+
* Main execution sequence.
76+
*
77+
* @private
78+
*/
79+
function main() {
80+
var len;
81+
var min;
82+
var max;
83+
var f;
84+
var i;
85+
86+
min = 1; // 10^min
87+
max = 6; // 10^max
88+
89+
for ( i = min; i <= max; i++ ) {
90+
len = pow( 10, i );
91+
f = createBenchmark( len );
92+
bench( format( '%s:dtype=float16,size=%d', pkg, len ), f );
93+
}
94+
}
95+
96+
main();

‎base/nans-like/docs/types/test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import nansLike = require( './index' );
2929

3030
nansLike( ones( 'float64', sh, ord ) ); // $ExpectType float64ndarray
3131
nansLike( ones( 'float32', sh, ord ) ); // $ExpectType float32ndarray
32+
nansLike( ones( 'float16', sh, ord ) ); // $ExpectType float16ndarray
3233
nansLike( ones( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray
3334
nansLike( ones( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray
3435
nansLike( ones( 'generic', sh, ord ) ); // $ExpectType genericndarray<number>

‎base/nans-like/examples/index.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var nansLike = require( './../lib' );
2626
var dt = [
2727
'float64',
2828
'float32',
29+
'float16',
2930
'complex128',
3031
'complex64',
3132
'generic'

‎base/nans-like/test/test.js‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' );
2727
var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' );
2828
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
2929
var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' );
30+
var isSameFloat16Array = require( '@stdlib/assert/is-same-float16array' );
3031
var isSameArray = require( '@stdlib/assert/is-same-array' );
3132
var Float64Array = require( '@stdlib/array/float64' );
3233
var Float32Array = require( '@stdlib/array/float32' );
34+
var Float16Array = require( '@stdlib/array/float16' );
3335
var Complex64Array = require( '@stdlib/array/complex64' );
3436
var Complex128Array = require( '@stdlib/array/complex128' );
3537
var instanceOf = require( '@stdlib/assert/instance-of' );
@@ -172,6 +174,48 @@ tape( 'the function returns a NaN-filled array (dtype=float32, non-base)', funct
172174
t.end();
173175
});
174176

177+
tape( 'the function returns a NaN-filled array (dtype=float16, base)', function test( t ) {
178+
var expected;
179+
var arr;
180+
var x;
181+
182+
expected = new Float16Array( [ NaN, NaN, NaN, NaN ] );
183+
184+
x = ones( 'float16', [ 2, 2 ], 'row-major' );
185+
arr = nansLike( x );
186+
187+
t.strictEqual( instanceOf( arr, base ), true, 'returns expected value' );
188+
t.strictEqual( String( getDType( arr ) ), 'float16', 'returns expected value' );
189+
t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' );
190+
t.strictEqual( isSameFloat16Array( getData( arr ), expected ), true, 'returns expected value' );
191+
t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' );
192+
193+
t.end();
194+
});
195+
196+
tape( 'the function returns a NaN-filled array (dtype=float16, non-base)', function test( t ) {
197+
var expected;
198+
var arr;
199+
var x;
200+
201+
expected = new Float16Array( [ NaN, NaN, NaN, NaN ] );
202+
203+
x = array( new Float16Array( 4 ), {
204+
'shape': [ 2, 2 ],
205+
'dtype': 'float16',
206+
'order': 'column-major'
207+
});
208+
arr = nansLike( x );
209+
210+
t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' );
211+
t.strictEqual( String( getDType( arr ) ), 'float16', 'returns expected value' );
212+
t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' );
213+
t.strictEqual( isSameFloat16Array( getData( arr ), expected ), true, 'returns expected value' );
214+
t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' );
215+
216+
t.end();
217+
});
218+
175219
tape( 'the function returns a NaN-filled array (dtype=complex128, base)', function test( t ) {
176220
var expected;
177221
var arr;

0 commit comments

Comments
 (0)