Skip to content

Commit d1def2c

Browse files
committed
Auto-generated commit
1 parent a26c25a commit d1def2c

4 files changed

Lines changed: 151 additions & 1 deletion

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+
- [`abd365a`](https://github.com/stdlib-js/stdlib/commit/abd365a80596e407afc42fe806b2c113857423d4) - add float16 dtype support to `ndarray/filter-map` [(#15234)](https://github.com/stdlib-js/stdlib/pull/15234)
1314
- [`551a13c`](https://github.com/stdlib-js/stdlib/commit/551a13c30bc3e5d0079e2163a759a037481b58ff) - add float16 dtype support to `ndarray/for-each` [(#15236)](https://github.com/stdlib-js/stdlib/pull/15236)
1415
- [`4ba080a`](https://github.com/stdlib-js/stdlib/commit/4ba080a0f00815a1e00c81a0a063724b4cedc268) - add float16 dtype support to `ndarray/nans-like` [(#15252)](https://github.com/stdlib-js/stdlib/pull/15252)
1516
- [`83e2790`](https://github.com/stdlib-js/stdlib/commit/83e2790a1e95b65d969b50cbe9da03a7623d98cf) - add float16 dtype support to `ndarray/nans` [(#15251)](https://github.com/stdlib-js/stdlib/pull/15251)
@@ -108,6 +109,7 @@ A total of 4 issues were closed in this release:
108109

109110
<details>
110111

112+
- [`abd365a`](https://github.com/stdlib-js/stdlib/commit/abd365a80596e407afc42fe806b2c113857423d4) - **feat:** add float16 dtype support to `ndarray/filter-map` [(#15234)](https://github.com/stdlib-js/stdlib/pull/15234) _(by Samarth Kolarkar)_
111113
- [`551a13c`](https://github.com/stdlib-js/stdlib/commit/551a13c30bc3e5d0079e2163a759a037481b58ff) - **feat:** add float16 dtype support to `ndarray/for-each` [(#15236)](https://github.com/stdlib-js/stdlib/pull/15236) _(by Samarth Kolarkar)_
112114
- [`4ba080a`](https://github.com/stdlib-js/stdlib/commit/4ba080a0f00815a1e00c81a0a063724b4cedc268) - **feat:** add float16 dtype support to `ndarray/nans-like` [(#15252)](https://github.com/stdlib-js/stdlib/pull/15252) _(by Samarth Kolarkar)_
113115
- [`83e2790`](https://github.com/stdlib-js/stdlib/commit/83e2790a1e95b65d969b50cbe9da03a7623d98cf) - **feat:** add float16 dtype support to `ndarray/nans` [(#15251)](https://github.com/stdlib-js/stdlib/pull/15251) _(by Samarth Kolarkar)_

‎filter-map/docs/types/index.d.ts‎

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
/* eslint-disable max-lines */
2424

25-
import { typedndarray, DataType, Order, float64ndarray, float32ndarray, complex128ndarray, complex64ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray } from '@stdlib/types/ndarray';
25+
import { typedndarray, DataType, Order, float64ndarray, float32ndarray, float16ndarray, complex128ndarray, complex64ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray } from '@stdlib/types/ndarray';
2626
import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex';
2727

2828
/**
@@ -139,6 +139,20 @@ interface Float32Options extends Options {
139139
dtype?: 'float32';
140140
}
141141

142+
/**
143+
* Interface describing function options.
144+
*/
145+
interface Float16Options extends Options {
146+
/**
147+
* Output ndarray data type.
148+
*
149+
* ## Notes
150+
*
151+
* - This option overrides using the input ndarray's inferred data type.
152+
*/
153+
dtype?: 'float16';
154+
}
155+
142156
/**
143157
* Interface describing function options.
144158
*/
@@ -355,6 +369,37 @@ declare function filterMap<V = unknown>( x: float64ndarray, fcn: Callback<number
355369
*/
356370
declare function filterMap<V = unknown>( x: float32ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float32ndarray;
357371

372+
/**
373+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
374+
*
375+
* @param x - input ndarray
376+
* @param fcn - callback function
377+
* @param thisArg - callback function execution context
378+
* @returns output ndarray
379+
*
380+
* @example
381+
* var Float16Array = require( '@stdlib/array/float16' );
382+
* var ndarray = require( '@stdlib/ndarray/ctor' );
383+
*
384+
* function scale( z ) {
385+
* if ( z > 5.0 ) {
386+
* return z * 10.0;
387+
* }
388+
* }
389+
*
390+
* var buffer = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
391+
* var shape = [ 2, 3 ];
392+
* var strides = [ 6, 1 ];
393+
* var offset = 1;
394+
*
395+
* var x = ndarray( 'float16', buffer, shape, strides, offset, 'row-major' );
396+
* // returns <ndarray>
397+
*
398+
* var y = filterMap( x, scale );
399+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
400+
*/
401+
declare function filterMap<V = unknown>( x: float16ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float16ndarray;
402+
358403
/**
359404
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
360405
*
@@ -767,6 +812,42 @@ declare function filterMap<V = unknown>( x: float64ndarray, options: OrderOption
767812
*/
768813
declare function filterMap<V = unknown>( x: float32ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float32ndarray;
769814

815+
/**
816+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
817+
*
818+
* @param x - input ndarray
819+
* @param options - function options
820+
* @param options.order - iteration order
821+
* @param fcn - callback function
822+
* @param thisArg - callback function execution context
823+
* @returns output ndarray
824+
*
825+
* @example
826+
* var Float16Array = require( '@stdlib/array/float16' );
827+
* var ndarray = require( '@stdlib/ndarray/ctor' );
828+
*
829+
* function scale( z ) {
830+
* if ( z > 5.0 ) {
831+
* return z * 10.0;
832+
* }
833+
* }
834+
*
835+
* var buffer = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
836+
* var shape = [ 2, 3 ];
837+
* var strides = [ 6, 1 ];
838+
* var offset = 1;
839+
*
840+
* var x = ndarray( 'float16', buffer, shape, strides, offset, 'row-major' );
841+
* // returns <ndarray>
842+
*
843+
* var opts = {
844+
* 'order': 'row-major'
845+
* };
846+
* var y = filterMap( x, opts, scale );
847+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
848+
*/
849+
declare function filterMap<V = unknown>( x: float16ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float16ndarray;
850+
770851
/**
771852
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
772853
*
@@ -1236,6 +1317,43 @@ declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarr
12361317
*/
12371318
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Float32Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): float32ndarray;
12381319

1320+
/**
1321+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
1322+
*
1323+
* @param x - input ndarray
1324+
* @param options - options
1325+
* @param options.dtype - output ndarray data type
1326+
* @param options.order - iteration order
1327+
* @param fcn - callback function
1328+
* @param thisArg - callback function execution context
1329+
* @returns output ndarray
1330+
*
1331+
* @example
1332+
* var Float64Array = require( '@stdlib/array/float64' );
1333+
* var ndarray = require( '@stdlib/ndarray/ctor' );
1334+
*
1335+
* function scale( z ) {
1336+
* if ( z > 5.0 ) {
1337+
* return z * 10.0;
1338+
* }
1339+
* }
1340+
*
1341+
* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1342+
* var shape = [ 2, 3 ];
1343+
* var strides = [ 6, 1 ];
1344+
* var offset = 1;
1345+
*
1346+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1347+
* // returns <ndarray>
1348+
*
1349+
* var opts = {
1350+
* 'dtype': 'float16'
1351+
* };
1352+
* var y = filterMap( x, opts, scale );
1353+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
1354+
*/
1355+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Float16Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): float16ndarray;
1356+
12391357
/**
12401358
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
12411359
*

‎filter-map/docs/types/test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ function identity3( x: ComplexLike ): ComplexLike {
7272
filterMap( zeros( 'float64', sh, ord ), identity1, {} ); // $ExpectType float64ndarray
7373
filterMap( zeros( 'float32', sh, ord ), identity1 ); // $ExpectType float32ndarray
7474
filterMap( zeros( 'float32', sh, ord ), identity1, {} ); // $ExpectType float32ndarray
75+
filterMap( zeros( 'float16', sh, ord ), identity1 ); // $ExpectType float16ndarray
76+
filterMap( zeros( 'float16', sh, ord ), identity1, {} ); // $ExpectType float16ndarray
7577
filterMap( zeros( 'complex64', sh, ord ), identity3 ); // $ExpectType complex64ndarray
7678
filterMap( zeros( 'complex64', sh, ord ), identity3, {} ); // $ExpectType complex64ndarray
7779
filterMap( zeros( 'complex128', sh, ord ), identity3 ); // $ExpectType complex128ndarray
@@ -100,6 +102,8 @@ function identity3( x: ComplexLike ): ComplexLike {
100102
filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'float64' }, fcn, {} ); // $ExpectType float64ndarray
101103
filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'float32' }, fcn ); // $ExpectType float32ndarray
102104
filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'float32' }, fcn, {} ); // $ExpectType float32ndarray
105+
filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'float16' }, fcn ); // $ExpectType float16ndarray
106+
filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'float16' }, fcn, {} ); // $ExpectType float16ndarray
103107
filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' }, fcn ); // $ExpectType complex64ndarray
104108
filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' }, fcn, {} ); // $ExpectType complex64ndarray
105109
filterMap( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' }, fcn ); // $ExpectType complex128ndarray
@@ -128,6 +132,8 @@ function identity3( x: ComplexLike ): ComplexLike {
128132
filterMap( zeros( 'float64', sh, ord ), { 'order': ord }, identity1, {} ); // $ExpectType float64ndarray
129133
filterMap( zeros( 'float32', sh, ord ), { 'order': ord }, identity1 ); // $ExpectType float32ndarray
130134
filterMap( zeros( 'float32', sh, ord ), { 'order': ord }, identity1, {} ); // $ExpectType float32ndarray
135+
filterMap( zeros( 'float16', sh, ord ), { 'order': ord }, identity1 ); // $ExpectType float16ndarray
136+
filterMap( zeros( 'float16', sh, ord ), { 'order': ord }, identity1, {} ); // $ExpectType float16ndarray
131137
filterMap( zeros( 'complex64', sh, ord ), { 'order': ord }, identity3 ); // $ExpectType complex64ndarray
132138
filterMap( zeros( 'complex64', sh, ord ), { 'order': ord }, identity3, {} ); // $ExpectType complex64ndarray
133139
filterMap( zeros( 'complex128', sh, ord ), { 'order': ord }, identity3 ); // $ExpectType complex128ndarray

‎filter-map/test/test.js‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ var shape2strides = require( './../../base/shape2strides' );
2727
var strides2offset = require( './../../base/strides2offset' );
2828
var Float64Array = require( '@stdlib/array/float64' );
2929
var Float32Array = require( '@stdlib/array/float32' );
30+
var Float16Array = require( '@stdlib/array/float16' );
3031
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
3132
var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' );
33+
var isSameFloat16Array = require( '@stdlib/assert/is-same-float16array' );
3234
var filterMap = require( './../lib' );
3335

3436

@@ -369,6 +371,17 @@ tape( 'the function filters and maps an array according to a callback function (
369371
]);
370372
t.strictEqual( isSameFloat32Array( y.data, expected ), true, 'returns expected value' );
371373

374+
opts = {
375+
'dtype': 'float16'
376+
};
377+
y = filterMap( x, opts, fcn );
378+
379+
expected = new Float16Array([
380+
10.0,
381+
30.0
382+
]);
383+
t.strictEqual( isSameFloat16Array( y.data, expected ), true, 'returns expected value' );
384+
372385
t.end();
373386

374387
function fcn( z ) {
@@ -418,6 +431,17 @@ tape( 'the function filters and maps an array according to a callback function (
418431
]);
419432
t.strictEqual( isSameFloat32Array( y.data, expected ), true, 'returns expected value' );
420433

434+
opts = {
435+
'dtype': 'float16'
436+
};
437+
y = filterMap( x, opts, fcn );
438+
439+
expected = new Float16Array([
440+
10.0,
441+
30.0
442+
]);
443+
t.strictEqual( isSameFloat16Array( y.data, expected ), true, 'returns expected value' );
444+
421445
t.end();
422446

423447
function fcn( z ) {

0 commit comments

Comments
 (0)