Skip to content

Commit 1023dd1

Browse files
committed
Auto-generated commit
1 parent 906157d commit 1023dd1

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ A total of 24 issues were closed in this release:
532532

533533
<details>
534534

535+
- [`9b660ce`](https://github.com/stdlib-js/stdlib/commit/9b660ceda07c2d62d1faccfe619da11579f631c6) - **test:** add `dtype` test _(by Athan Reines)_
535536
- [`6d74243`](https://github.com/stdlib-js/stdlib/commit/6d742438beb8e7fe0de4ecfbc82083da16a0a83c) - **fix:** ensure correct type when providing a `dtype` option _(by Athan Reines)_
536537
- [`0ed631d`](https://github.com/stdlib-js/stdlib/commit/0ed631d96dae3b796882c441f79505275afbc4c0) - **feat:** add `dtype` option support in `ndarray/flatten` [(#8091)](https://github.com/stdlib-js/stdlib/pull/8091) _(by Muhammad Haris, Athan Reines)_
537538
- [`724283b`](https://github.com/stdlib-js/stdlib/commit/724283b0bc5d2eb8bf48491c954c6a119330c1f5) - **feat:** add `ndarray/base/nullary-strided1d-dispatch-factory` [(#7828)](https://github.com/stdlib-js/stdlib/pull/7828) _(by Muhammad Haris, Athan Reines, stdlib-bot)_

flatten/test/test.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424

2525
var tape = require( 'tape' );
2626
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
27+
var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' );
2728
var zeros = require( './../../zeros' );
2829
var ndarray = require( './../../ctor' );
2930
var Float64Array = require( '@stdlib/array/float64' );
31+
var Float32Array = require( '@stdlib/array/float32' );
3032
var getDType = require( './../../dtype' );
3133
var getShape = require( './../../shape' );
3234
var getOrder = require( './../../order' );
@@ -1391,3 +1393,50 @@ tape( 'the function supports flattening a one-dimensional input ndarray (order=a
13911393

13921394
t.end();
13931395
});
1396+
1397+
tape( 'the function supports specifying the output ndarray data type', function test( t ) {
1398+
var expected;
1399+
var xbuf;
1400+
var ord;
1401+
var sh;
1402+
var st;
1403+
var dt;
1404+
var o;
1405+
var x;
1406+
var y;
1407+
1408+
dt = 'float64';
1409+
ord = 'row-major';
1410+
sh = [ 2, 2, 2 ];
1411+
st = shape2strides( sh, ord );
1412+
o = strides2offset( sh, st );
1413+
1414+
/*
1415+
* [
1416+
* [
1417+
* [ 1.0, 2.0 ],
1418+
* [ 3.0, 4.0 ]
1419+
* ],
1420+
* [
1421+
* [ 5.0, 6.0 ],
1422+
* [ 7.0, 8.0 ]
1423+
* ]
1424+
* ]
1425+
*/
1426+
xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
1427+
x = new ndarray( dt, xbuf, sh, st, o, ord );
1428+
1429+
y = flatten( x, {
1430+
'dtype': 'float32'
1431+
});
1432+
expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
1433+
1434+
t.notEqual( y, x, 'returns expected value' );
1435+
t.notEqual( getData( y ), xbuf, 'returns expected value' );
1436+
t.strictEqual( isSameFloat32Array( getData( y ), expected ), true, 'returns expected value' );
1437+
t.deepEqual( getShape( y ), [ 8 ], 'returns expected value' );
1438+
t.strictEqual( getDType( y ), 'float32', 'returns expected value' );
1439+
t.strictEqual( getOrder( y ), ord, 'returns expected value' );
1440+
1441+
t.end();
1442+
});

0 commit comments

Comments
 (0)