Skip to content

Commit d568531

Browse files
committed
Auto-generated commit
1 parent 860df0c commit d568531

5 files changed

Lines changed: 167 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
<section class="release" id="unreleased">
66

7-
## Unreleased (2026-09-23)
7+
## Unreleased (2026-09-24)
88

99
<section class="features">
1010

1111
### Features
1212

13+
- [`13dd490`](https://github.com/stdlib-js/stdlib/commit/13dd4907d9a897cffce419ff738b46f74708d19b) - add float16 dtype support to `ndarray/base/ones-like` [(#15494)](https://github.com/stdlib-js/stdlib/pull/15494)
1314
- [`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)
1415
- [`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)
1516
- [`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)
@@ -122,6 +123,7 @@ A total of 4 issues were closed in this release:
122123

123124
<details>
124125

126+
- [`13dd490`](https://github.com/stdlib-js/stdlib/commit/13dd4907d9a897cffce419ff738b46f74708d19b) - **feat:** add float16 dtype support to `ndarray/base/ones-like` [(#15494)](https://github.com/stdlib-js/stdlib/pull/15494) _(by Samarth Kolarkar)_
125127
- [`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)_
126128
- [`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)_
127129
- [`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)_

‎base/ones-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::base:dtype=float32', pkg ), function benchmark( b ) {
7474
b.end();
7575
});
7676

77+
bench( format( '%s::base: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 = onesLike( 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::base: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 onesLike = 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 = onesLike( 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::base:dtype=float16,size=%d', pkg, len ), f );
93+
}
94+
}
95+
96+
main();

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

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

3030
onesLike( ones( 'float64', sh, ord ) ); // $ExpectType float64ndarray
3131
onesLike( ones( 'float32', sh, ord ) ); // $ExpectType float32ndarray
32+
onesLike( ones( 'float16', sh, ord ) ); // $ExpectType float16ndarray
3233
onesLike( ones( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray
3334
onesLike( ones( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray
3435
onesLike( ones( 'int32', sh, ord ) ); // $ExpectType int32ndarray

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var tape = require( 'tape' );
2424
var Float64Array = require( '@stdlib/array/float64' );
2525
var Float32Array = require( '@stdlib/array/float32' );
26+
var Float16Array = require( '@stdlib/array/float16' );
2627
var Int32Array = require( '@stdlib/array/int32' );
2728
var Uint32Array = require( '@stdlib/array/uint32' );
2829
var Int16Array = require( '@stdlib/array/int16' );
@@ -178,6 +179,50 @@ tape( 'the function returns a ones-filled array (dtype=float32, non-base)', func
178179
t.end();
179180
});
180181

182+
tape( 'the function returns a ones-filled array (dtype=float16, base)', function test( t ) {
183+
var expected;
184+
var arr;
185+
var x;
186+
187+
expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0 ] );
188+
189+
x = ones( 'float16', [ 2, 2 ], 'row-major' );
190+
arr = onesLike( x );
191+
192+
t.strictEqual( instanceOf( arr, base ), true, 'returns expected value' );
193+
t.strictEqual( String( getDType( arr ) ), 'float16', 'returns expected value' );
194+
t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' );
195+
t.strictEqual( instanceOf( getData( arr ), Float16Array ), true, 'returns expected value' );
196+
t.deepEqual( getData( arr ), expected, 'returns expected value' );
197+
t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' );
198+
199+
t.end();
200+
});
201+
202+
tape( 'the function returns a ones-filled array (dtype=float16, non-base)', function test( t ) {
203+
var expected;
204+
var arr;
205+
var x;
206+
207+
expected = new Float16Array( [ 1.0, 1.0, 1.0, 1.0 ] );
208+
209+
x = array( new Float16Array( 4 ), {
210+
'shape': [ 2, 2 ],
211+
'dtype': 'float16',
212+
'order': 'column-major'
213+
});
214+
arr = onesLike( x );
215+
216+
t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' );
217+
t.strictEqual( String( getDType( arr ) ), 'float16', 'returns expected value' );
218+
t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' );
219+
t.strictEqual( instanceOf( getData( arr ), Float16Array ), true, 'returns expected value' );
220+
t.deepEqual( getData( arr ), expected, 'returns expected value' );
221+
t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' );
222+
223+
t.end();
224+
});
225+
181226
tape( 'the function returns a ones-filled array (dtype=int32, base)', function test( t ) {
182227
var expected;
183228
var arr;

0 commit comments

Comments
 (0)