Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/node_modules/@stdlib/array/convert/benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,31 @@ bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) {
b.end();
});

bench( format( '%s:dtype=float16', pkg ), function benchmark( b ) {
var arr;
var out;
var i;

arr = [];
for ( i = 0; i < 10; i++ ) {
arr.push( i );
}
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr[ 0 ] += 1;
out = convertArray( arr, 'float16' );
if ( out.length !== arr.length ) {
b.fail( 'should have expected length' );
}
}
b.toc();
if ( !isCollection( out ) ) {
b.fail( 'should return an array-like object' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) {
var arr;
var out;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ function main() {
f = createBenchmark( len, 'float32' );
bench( format( '%s:len=%d,dtype=float32', pkg, len ), f );

f = createBenchmark( len, 'float16' );
bench( format( '%s:len=%d,dtype=float16', pkg, len ), f );

f = createBenchmark( len, 'bool' );
bench( format( '%s:len=%d,dtype=bool', pkg, len ), f );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function main()
dtypes = [
Float64,
Float32,
Float16,
Int32,
Int16,
Int8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def main():
dtypes = [
"float64",
"float32",
"float16",
"int32",
"int16",
"int8",
Expand All @@ -120,8 +121,7 @@ def main():
n = 1
while n < 1e7:
n *= 10
for i in range(0, len(dtypes)):
dtype = dtypes[i]
for dtype in dtypes:
name = ":len="+str(n)+",dtype="+dtype
setup = "import numpy as np;"
setup += "A = np.ones([1,"+str(n)+"], dtype='float64');"
Expand Down
1 change: 1 addition & 0 deletions lib/node_modules/@stdlib/array/convert/docs/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import convert = require( './index' );
{
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float64' ); // $ExpectType Float64Array
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float32' ); // $ExpectType Float32Array
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float16' ); // $ExpectType Float16ArrayFallback
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'int32' ); // $ExpectType Int32Array
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'int16' ); // $ExpectType Int16Array
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'int8' ); // $ExpectType Int8Array
Expand Down
14 changes: 14 additions & 0 deletions lib/node_modules/@stdlib/array/convert/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
var tape = require( 'tape' );
var Float64Array = require( '@stdlib/array/float64' );
var Float32Array = require( '@stdlib/array/float32' );
var Float16Array = require( '@stdlib/array/float16' );
var Int16Array = require( '@stdlib/array/int16' );
var Int32Array = require( '@stdlib/array/int32' );
var Int8Array = require( '@stdlib/array/int8' );
Expand All @@ -38,6 +39,7 @@ var BooleanArray = require( '@stdlib/array/bool' );
var isArray = require( '@stdlib/assert/is-array' );
var isFloat64Array = require( '@stdlib/assert/is-float64array' );
var isFloat32Array = require( '@stdlib/assert/is-float32array' );
var isFloat16Array = require( '@stdlib/assert/is-float16array' );
var isInt16Array = require( '@stdlib/assert/is-int16array' );
var isInt32Array = require( '@stdlib/assert/is-int32array' );
var isInt8Array = require( '@stdlib/assert/is-int8array' );
Expand Down Expand Up @@ -136,6 +138,7 @@ tape( 'the function converts an array to an array of a different data type', fun
dtypes = [
'float64',
'float32',
'float16',
'generic',
'int16',
'int32',
Expand All @@ -149,6 +152,7 @@ tape( 'the function converts an array to an array of a different data type', fun
expected = [
[ new Float64Array( [ -1.0, 0.0, 1.0 ] ), isFloat64Array ],
[ new Float32Array( [ -1.0, 0.0, 1.0 ] ), isFloat32Array ],
[ new Float16Array( [ -1.0, 0.0, 1.0 ] ), isFloat16Array ],
[ arr, isArray ],
[ new Int16Array( [ -1, 0, 1 ] ), isInt16Array ],
[ new Int32Array( [ -1, 0, 1 ] ), isInt32Array ],
Expand Down Expand Up @@ -179,6 +183,7 @@ tape( 'the function converts an array to an array of a different data type (acce
dtypes = [
'float64',
'float32',
'float16',
'generic',
'int16',
'int32',
Expand All @@ -197,6 +202,7 @@ tape( 'the function converts an array to an array of a different data type (acce
expected = [
[ new Float64Array( [ -1.0, 0.0, 1.0 ] ), isFloat64Array ],
[ new Float32Array( [ -1.0, 0.0, 1.0 ] ), isFloat32Array ],
[ new Float16Array( [ -1.0, 0.0, 1.0 ] ), isFloat16Array ],
[ [ -1, 0, 1 ], isArray ],
[ new Int16Array( [ -1, 0, 1 ] ), isInt16Array ],
[ new Int32Array( [ -1, 0, 1 ] ), isInt32Array ],
Expand Down Expand Up @@ -461,6 +467,7 @@ tape( 'the function converts an array to an array of a different data type (comp
dtypes = [
'float64',
'float32',
'float16',
'int16',
'int32',
'int8',
Expand All @@ -473,6 +480,7 @@ tape( 'the function converts an array to an array of a different data type (comp
expected = [
[ new Float64Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat64Array ],
[ new Float32Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat32Array ],
[ new Float16Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat16Array ],
[ new Int16Array( [ -1, 0, 1, 2 ] ), isInt16Array ],
[ new Int32Array( [ -1, 0, 1, 2 ] ), isInt32Array ],
[ new Int8Array( [ -1, 0, 1, 2 ] ), isInt8Array ],
Expand Down Expand Up @@ -502,6 +510,7 @@ tape( 'the function converts an array to an array of a different data type (comp
dtypes = [
'float64',
'float32',
'float16',
'int16',
'int32',
'int8',
Expand All @@ -514,6 +523,7 @@ tape( 'the function converts an array to an array of a different data type (comp
expected = [
[ new Float64Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat64Array ],
[ new Float32Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat32Array ],
[ new Float16Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat16Array ],
[ new Int16Array( [ -1, 0, 1, 2 ] ), isInt16Array ],
[ new Int32Array( [ -1, 0, 1, 2 ] ), isInt32Array ],
[ new Int8Array( [ -1, 0, 1, 2 ] ), isInt8Array ],
Expand Down Expand Up @@ -543,6 +553,7 @@ tape( 'the function converts an array to an array of a different data type (bool
dtypes = [
'float64',
'float32',
'float16',
'int16',
'int32',
'int8',
Expand All @@ -555,6 +566,7 @@ tape( 'the function converts an array to an array of a different data type (bool
expected = [
[ new Float64Array( [ 1.0, 0.0, 1.0 ] ), isFloat64Array ],
[ new Float32Array( [ 1.0, 0.0, 1.0 ] ), isFloat32Array ],
[ new Float16Array( [ 1.0, 0.0, 1.0 ] ), isFloat16Array ],
[ new Int16Array( [ 1, 0, 1 ] ), isInt16Array ],
[ new Int32Array( [ 1, 0, 1 ] ), isInt32Array ],
[ new Int8Array( [ 1, 0, 1 ] ), isInt8Array ],
Expand Down Expand Up @@ -673,6 +685,7 @@ tape( 'the function converts an array to an array of a different data type (larg
dtypes = [
'float64',
'float32',
'float16',
'generic',
'int16',
'int32',
Expand All @@ -692,6 +705,7 @@ tape( 'the function converts an array to an array of a different data type (larg
expected = [
isFloat64Array,
isFloat32Array,
isFloat16Array,
isArray,
isInt16Array,
isInt32Array,
Expand Down
Loading