diff --git a/lib/node_modules/@stdlib/array/from-scalar/README.md b/lib/node_modules/@stdlib/array/from-scalar/README.md
index 81a4796342d5..fca2bdcd4e7a 100644
--- a/lib/node_modules/@stdlib/array/from-scalar/README.md
+++ b/lib/node_modules/@stdlib/array/from-scalar/README.md
@@ -51,7 +51,8 @@ var x = scalar2array( 3.0 );
If not provided a `dtype` argument and `value`
-- is a `number`, the default [data type][@stdlib/array/dtypes] is the [default][@stdlib/array/defaults] real-valued floating-point data type.
+- is a number, the default [data type][@stdlib/array/dtypes] is the [default][@stdlib/array/defaults] real-valued floating-point data type.
+- is a boolean, the default [data type][@stdlib/array/dtypes] is the [default][@stdlib/array/defaults] boolean data type.
- is a complex number object of a known data type, the data type is the same as the provided value.
- is a complex number object of an unknown data type, the default [data type][@stdlib/array/dtypes] is the [default][@stdlib/array/defaults] complex-valued floating-point data type.
- is any other value type, the default [data type][@stdlib/array/dtypes] is `'generic'`.
diff --git a/lib/node_modules/@stdlib/array/from-scalar/benchmark/benchmark.js b/lib/node_modules/@stdlib/array/from-scalar/benchmark/benchmark.js
index 95a5a8bf79de..924637416d7e 100644
--- a/lib/node_modules/@stdlib/array/from-scalar/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/array/from-scalar/benchmark/benchmark.js
@@ -169,6 +169,32 @@ bench( pkg+'::default,complex-like', function benchmark( b ) {
b.end();
});
+bench( pkg+'::default,bool', function benchmark( b ) {
+ var values;
+ var v;
+ var i;
+
+ values = [
+ true,
+ false
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = scalar2array( values[ i%values.length ] );
+ if ( v.length !== 1 ) {
+ b.fail( 'should return a single-element array' );
+ }
+ }
+ console.log( v );
+ b.toc();
+ if ( !isCollection ) {
+ b.fail( 'should return an array' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
bench( pkg+':dtype=float64', function benchmark( b ) {
var values;
var v;
@@ -403,6 +429,31 @@ bench( pkg+':dtype=uint8c', function benchmark( b ) {
b.end();
});
+bench( pkg+':dtype=bool', function benchmark( b ) {
+ var values;
+ var v;
+ var i;
+
+ values = [
+ true,
+ false
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = scalar2array( values[ i%values.length ], 'bool' );
+ if ( v.length !== 1 ) {
+ b.fail( 'should return a single-element array' );
+ }
+ }
+ b.toc();
+ if ( !isCollection ) {
+ b.fail( 'should return an array' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
bench( pkg+'::real:dtype=complex128', function benchmark( b ) {
var values;
var v;
diff --git a/lib/node_modules/@stdlib/array/from-scalar/docs/repl.txt b/lib/node_modules/@stdlib/array/from-scalar/docs/repl.txt
index 43fa375cbb62..0a66ea6b1027 100644
--- a/lib/node_modules/@stdlib/array/from-scalar/docs/repl.txt
+++ b/lib/node_modules/@stdlib/array/from-scalar/docs/repl.txt
@@ -17,6 +17,7 @@
- is a number, the default data type is the default real-valued
floating-point data type.
+ - is a boolean, the default data type is the default boolean data type.
- is a complex number object of a known complex data type, the data type
is the same as the provided value.
- is a complex number object of an unknown data type, the default data
diff --git a/lib/node_modules/@stdlib/array/from-scalar/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/from-scalar/docs/types/index.d.ts
index f86459a17ae3..dcc45a44e95a 100644
--- a/lib/node_modules/@stdlib/array/from-scalar/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/array/from-scalar/docs/types/index.d.ts
@@ -21,7 +21,7 @@
///
import { ComplexLike, Complex64, Complex128 } from '@stdlib/types/complex';
-import { DataType, Complex128Array, Complex64Array } from '@stdlib/types/array';
+import { DataType, Complex128Array, Complex64Array, BooleanArray } from '@stdlib/types/array';
/**
* Returns a single-element array containing a provided scalar value.
@@ -49,6 +49,19 @@ declare function scalar2array( value: number, dtype: 'float64' ): Float64Array;
*/
declare function scalar2array( value: number, dtype: 'float32' ): Float32Array;
+/**
+* Returns a single-element array containing a provided scalar value.
+*
+* @param value - scalar value
+* @param dtype - output array data type
+* @returns output array
+*
+* @example
+* var x = scalar2array( true, 'bool' );
+* // returns
+*/
+declare function scalar2array( value: any, dtype: 'bool' ): BooleanArray;
+
/**
* Returns a single-element array containing a provided scalar value.
*
@@ -208,6 +221,19 @@ declare function scalar2array( value: T, dtype: 'generic' ): Array<
*/
declare function scalar2array( value: number ): Float64Array;
+/**
+* Returns a single-element array containing a provided scalar value.
+*
+* @param value - scalar value
+* @param dtype - output array data type
+* @returns output array
+*
+* @example
+* var x = scalar2array( true );
+* // returns
+*/
+declare function scalar2array( value: boolean ): BooleanArray;
+
/**
* Returns a single-element array containing a provided scalar value.
*
@@ -249,7 +275,8 @@ declare function scalar2array( value: Complex128 | ComplexLike ): Complex128Arra
*
* - If a `dtype` argument is not provided and `value`
*
-* - is a `number`, the default data type is the default real-valued floating-point data type.
+* - is a number, the default data type is the default real-valued floating-point data type.
+* - is a boolean, the default data type is the default boolean data type.
* - is a complex number object of a known complex data type, the data type is the same as the provided value.
* - is a complex number object of an unknown complex data type, the default data type is the default complex-valued floating-point data type.
* - is any other value type, the default data type is `'generic'`.
diff --git a/lib/node_modules/@stdlib/array/from-scalar/docs/types/test.ts b/lib/node_modules/@stdlib/array/from-scalar/docs/types/test.ts
index f13cbe63ae7d..700493ab68c9 100644
--- a/lib/node_modules/@stdlib/array/from-scalar/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/array/from-scalar/docs/types/test.ts
@@ -29,12 +29,14 @@ import array2scalar = require( './index' );
array2scalar( new Complex128( 3.0, 4.0 ) ); // $ExpectType Complex128Array
array2scalar( new Complex64( 3.0, 4.0 ) ); // $ExpectType Complex64Array
array2scalar( { 're': 3.0, 'im': 4.0 } ); // $ExpectType Complex128Array
+ array2scalar( true ); // $ExpectType BooleanArray
array2scalar( null ); // $ExpectType null[]
array2scalar( 1.0, 'float64' ); // $ExpectType Float64Array
array2scalar( 1.0, 'float32' ); // $ExpectType Float32Array
array2scalar( 1.0, 'complex128' ); // $ExpectType Complex128Array
array2scalar( 1.0, 'complex64' ); // $ExpectType Complex64Array
+ array2scalar( true, 'bool' ); // $ExpectType BooleanArray
array2scalar( 1.0, 'int32' ); // $ExpectType Int32Array
array2scalar( 1.0, 'int16' ); // $ExpectType Int16Array
array2scalar( 1.0, 'int8' ); // $ExpectType Int8Array
diff --git a/lib/node_modules/@stdlib/array/from-scalar/lib/main.js b/lib/node_modules/@stdlib/array/from-scalar/lib/main.js
index acc66060eb33..89d792c1620e 100644
--- a/lib/node_modules/@stdlib/array/from-scalar/lib/main.js
+++ b/lib/node_modules/@stdlib/array/from-scalar/lib/main.js
@@ -20,8 +20,10 @@
// MODULES //
+var isComplexDataType = require( '@stdlib/array/base/assert/is-complex-floating-point-data-type' );
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
var isComplexLike = require( '@stdlib/assert/is-complex-like' );
+var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
var isAccessorArray = require( '@stdlib/array/base/assert/is-accessor-array' );
var accessorSetter = require( '@stdlib/array/base/accessor-setter' );
var setter = require( '@stdlib/array/base/setter' );
@@ -34,6 +36,7 @@ var defaults = require( '@stdlib/array/defaults' );
var DEFAULT_REAL = defaults.get( 'dtypes.real_floating_point' );
var DEFAULT_CMPLX = defaults.get( 'dtypes.complex_floating_point' );
+var DEFAULT_BOOL = defaults.get( 'dtypes.boolean' );
// MAIN //
@@ -45,7 +48,8 @@ var DEFAULT_CMPLX = defaults.get( 'dtypes.complex_floating_point' );
*
* - If a `dtype` option is not provided and `value`
*
-* - is a `number`, the default data type is the default real-valued floating-point data type.
+* - is a number, the default data type is the default real-valued floating-point data type.
+* - is a boolean, the default data type is the default boolean data type.
* - is a complex number object of a known complex data type, the data type is the same as the provided value.
* - is a complex number object of an unknown complex data type, the default data type is the default complex-valued floating-point data type.
* - is any other value type, the default data type is `'generic'`.
@@ -74,6 +78,8 @@ function scalar2array( value ) {
if ( arguments.length < 2 ) {
if ( flg ) {
dt = DEFAULT_REAL;
+ } else if ( isBoolean( value ) ) {
+ dt = DEFAULT_BOOL;
} else if ( isComplexLike( value ) ) {
dt = dtype( value );
if ( dt === null ) {
@@ -86,7 +92,7 @@ function scalar2array( value ) {
dt = arguments[ 1 ];
}
out = zeros( 1, dt ); // delegate dtype validation to `zeros`
- if ( /^complex/.test( dt ) && flg ) {
+ if ( flg && isComplexDataType( dt ) ) {
v = [ value, 0.0 ]; // note: we're assuming that the ComplexXXArray setter accepts an array of interleaved real and imaginary components
} else {
v = value;
diff --git a/lib/node_modules/@stdlib/array/from-scalar/test/test.js b/lib/node_modules/@stdlib/array/from-scalar/test/test.js
index 7ced8263edf8..1f968fda3738 100644
--- a/lib/node_modules/@stdlib/array/from-scalar/test/test.js
+++ b/lib/node_modules/@stdlib/array/from-scalar/test/test.js
@@ -25,9 +25,11 @@ var Complex128 = require( '@stdlib/complex/float64/ctor' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var Complex128Array = require( '@stdlib/array/complex128' );
var Complex64Array = require( '@stdlib/array/complex64' );
+var BooleanArray = require( '@stdlib/array/bool' );
var Float64Array = require( '@stdlib/array/float64' );
var Float32Array = require( '@stdlib/array/float32' );
var Int32Array = require( '@stdlib/array/int32' );
+var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' );
var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' );
var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' );
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
@@ -78,6 +80,17 @@ tape( 'the function returns a single element containing a provided scalar value
t.end();
});
+tape( 'the function returns a single element containing a provided scalar value (default, bool)', function test( t ) {
+ var expected;
+ var actual;
+
+ actual = array2scalar( true );
+ expected = new BooleanArray( [ true ] );
+
+ t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' );
+ t.end();
+});
+
tape( 'the function returns a single element containing a provided scalar value (default, complex128)', function test( t ) {
var expected;
var actual;
@@ -172,6 +185,22 @@ tape( 'the function returns a single element containing a provided scalar value
t.end();
});
+tape( 'the function returns a single element containing a provided scalar value (dtype=bool)', function test( t ) {
+ var expected;
+ var actual;
+
+ actual = array2scalar( false, 'bool' );
+ expected = new BooleanArray( [ false ] );
+
+ t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' );
+
+ actual = array2scalar( true, 'bool' );
+ expected = new BooleanArray( [ true ] );
+
+ t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' );
+ t.end();
+});
+
tape( 'the function returns a single element containing a provided scalar value (dtype=complex128, complex)', function test( t ) {
var expected;
var actual;