From 3dccae1ce718ad8ecddf0f5ca71864477bee80a9 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Fri, 28 Jun 2024 15:41:32 +0530 Subject: [PATCH 01/10] feat: add boolean dtype support to array/from-scalar --- .../@stdlib/array/from-scalar/README.md | 1 + .../array/from-scalar/benchmark/benchmark.js | 26 +++++++++++++++++++ .../@stdlib/array/from-scalar/docs/repl.txt | 2 ++ .../array/from-scalar/docs/types/index.d.ts | 15 ++++++++++- .../array/from-scalar/docs/types/test.ts | 1 + .../@stdlib/array/from-scalar/lib/main.js | 3 +++ .../@stdlib/array/from-scalar/test/test.js | 24 +++++++++++++++++ 7 files changed, 71 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/from-scalar/README.md b/lib/node_modules/@stdlib/array/from-scalar/README.md index 81a4796342d5..bc303a416793 100644 --- a/lib/node_modules/@stdlib/array/from-scalar/README.md +++ b/lib/node_modules/@stdlib/array/from-scalar/README.md @@ -54,6 +54,7 @@ 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 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 a boolean value, the default [data type][@stdlib/array/dtypes] is the [default][@stdlib/array/defaults] boolean data type. - is any other value type, the default [data type][@stdlib/array/dtypes] is `'generic'`. To explicitly specify the [data type][@stdlib/array/dtypes] of the returned array, provide a `dtype` argument. 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..0fd8262360ab 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+':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 ] ); + 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; 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..38ffffb4adad 100644 --- a/lib/node_modules/@stdlib/array/from-scalar/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/from-scalar/docs/repl.txt @@ -21,6 +21,8 @@ is the same as the provided value. - is a complex number object of an unknown data type, the default data type is the default complex-valued floating-point data type. + - is a boolean value, the default data type is the default boolean data + type. - is any other value type, the default data type is 'generic'. Returns 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..0e509a6cad6e 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: boolean, dtype: 'bool' ): BooleanArray; + /** * Returns a single-element array containing a provided scalar value. * 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..1bbc68df4744 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 @@ -35,6 +35,7 @@ import array2scalar = require( './index' ); 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..84654287c07c 100644 --- a/lib/node_modules/@stdlib/array/from-scalar/lib/main.js +++ b/lib/node_modules/@stdlib/array/from-scalar/lib/main.js @@ -22,6 +22,7 @@ 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' ); @@ -79,6 +80,8 @@ function scalar2array( value ) { if ( dt === null ) { dt = DEFAULT_CMPLX; } + } else if ( isBoolean( value ) ) { + dt = 'bool'; } else { dt = 'generic'; } 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..ff133b0e7c9d 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,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 (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' ); + t.end(); +}); + tape( 'the function returns a single element containing a provided scalar value (dtype=complex128, complex)', function test( t ) { var expected; var actual; From b4c42085966a981f98e7fe3d692ccbe7e70d7e0b Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Fri, 28 Jun 2024 22:42:01 +0530 Subject: [PATCH 02/10] refactor: update the typescript declaration --- .../array/from-scalar/docs/types/index.d.ts | 16 +++++++++++++++- .../@stdlib/array/from-scalar/docs/types/test.ts | 1 + .../@stdlib/array/from-scalar/lib/main.js | 5 +++-- 3 files changed, 19 insertions(+), 3 deletions(-) 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 0e509a6cad6e..384279bfea5b 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 @@ -60,7 +60,7 @@ declare function scalar2array( value: number, dtype: 'float32' ): Float32Array; * var x = scalar2array( true, 'bool' ); * // returns */ -declare function scalar2array( value: boolean, dtype: 'bool' ): BooleanArray; +declare function scalar2array( value: any, dtype: 'bool' ): BooleanArray; /** * Returns a single-element array containing a provided scalar value. @@ -221,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. * @@ -265,6 +278,7 @@ declare function scalar2array( value: Complex128 | ComplexLike ): Complex128Arra * - is a `number`, the default data type is the default real-valued floating-point 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 a boolean value, the default data type is the boolean data type. * - is any other value type, the default data type is `'generic'`. * * @param value - scalar value 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 1bbc68df4744..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,6 +29,7 @@ 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 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 84654287c07c..b98b817f77be 100644 --- a/lib/node_modules/@stdlib/array/from-scalar/lib/main.js +++ b/lib/node_modules/@stdlib/array/from-scalar/lib/main.js @@ -49,6 +49,7 @@ var DEFAULT_CMPLX = defaults.get( 'dtypes.complex_floating_point' ); * - is a `number`, the default data type is the default real-valued floating-point 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 a boolean value, the default data type is the boolean data type. * - is any other value type, the default data type is `'generic'`. * * @param {*} value - scalar value @@ -75,13 +76,13 @@ function scalar2array( value ) { if ( arguments.length < 2 ) { if ( flg ) { dt = DEFAULT_REAL; + } else if ( isBoolean( value ) ) { + dt = 'bool'; } else if ( isComplexLike( value ) ) { dt = dtype( value ); if ( dt === null ) { dt = DEFAULT_CMPLX; } - } else if ( isBoolean( value ) ) { - dt = 'bool'; } else { dt = 'generic'; } From 3814687e93dc13c1bdc26ae0cf4e7ccaf839e3c7 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 28 Jun 2024 23:56:07 -0700 Subject: [PATCH 03/10] bench: fix description and add benchmark --- .../array/from-scalar/benchmark/benchmark.js | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) 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 0fd8262360ab..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,7 +169,7 @@ bench( pkg+'::default,complex-like', function benchmark( b ) { b.end(); }); -bench( pkg+':dtype=bool', function benchmark( b ) { +bench( pkg+'::default,bool', function benchmark( b ) { var values; var v; var i; @@ -429,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; From c0078e58c4e8bb3d77d63a32bb4267257cf84e6a Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 28 Jun 2024 23:57:35 -0700 Subject: [PATCH 04/10] style: remove backticks --- .../@stdlib/array/from-scalar/docs/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 384279bfea5b..6f3bd317a588 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 @@ -275,7 +275,7 @@ 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 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 a boolean value, the default data type is the boolean data type. From 2d6017f0158ada5b6243c5166614ff832fbabdd3 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 28 Jun 2024 23:58:29 -0700 Subject: [PATCH 05/10] docs: update copy --- .../@stdlib/array/from-scalar/docs/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6f3bd317a588..b2e49418a1a8 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 @@ -278,7 +278,7 @@ declare function scalar2array( value: Complex128 | ComplexLike ): Complex128Arra * - is a number, the default data type is the default real-valued floating-point 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 a boolean value, the default data type is the boolean data type. +* - is a boolean, the default data type is the boolean data type. * - is any other value type, the default data type is `'generic'`. * * @param value - scalar value From a01a6090f87369aa4acbc9c26b532296a58c8280 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 28 Jun 2024 23:59:00 -0700 Subject: [PATCH 06/10] docs: update copy --- .../@stdlib/array/from-scalar/docs/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b2e49418a1a8..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 @@ -276,9 +276,9 @@ 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 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 a boolean, the default data type is the boolean data type. * - is any other value type, the default data type is `'generic'`. * * @param value - scalar value From 7a6f588b8bb895bd2f0aec6a0de8e629d5fdf9e9 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 28 Jun 2024 23:59:38 -0700 Subject: [PATCH 07/10] docs: update copy --- lib/node_modules/@stdlib/array/from-scalar/docs/repl.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 38ffffb4adad..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,12 +17,11 @@ - 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 type is the default complex-valued floating-point data type. - - is a boolean value, the default data type is the default boolean data - type. - is any other value type, the default data type is 'generic'. Returns From 23523cdb61117493b499ecbdeb470ab89e91ff02 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 29 Jun 2024 00:03:43 -0700 Subject: [PATCH 08/10] refactor: query default boolean data type --- lib/node_modules/@stdlib/array/from-scalar/lib/main.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 b98b817f77be..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,6 +20,7 @@ // 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; @@ -35,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 // @@ -46,10 +48,10 @@ 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 a boolean value, the default data type is the boolean data type. * - is any other value type, the default data type is `'generic'`. * * @param {*} value - scalar value @@ -77,7 +79,7 @@ function scalar2array( value ) { if ( flg ) { dt = DEFAULT_REAL; } else if ( isBoolean( value ) ) { - dt = 'bool'; + dt = DEFAULT_BOOL; } else if ( isComplexLike( value ) ) { dt = dtype( value ); if ( dt === null ) { @@ -90,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; From 2176f55cee885ea3a7be577e8d664a6ede4b7ef5 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 29 Jun 2024 00:04:56 -0700 Subject: [PATCH 09/10] test: add test case --- lib/node_modules/@stdlib/array/from-scalar/test/test.js | 5 +++++ 1 file changed, 5 insertions(+) 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 ff133b0e7c9d..1f968fda3738 100644 --- a/lib/node_modules/@stdlib/array/from-scalar/test/test.js +++ b/lib/node_modules/@stdlib/array/from-scalar/test/test.js @@ -192,6 +192,11 @@ tape( 'the function returns a single element containing a provided scalar value 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(); }); From a61b3af25fdb2dbae7490f4c702c7d3fa5150ebe Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 29 Jun 2024 00:05:48 -0700 Subject: [PATCH 10/10] docs: update copy --- lib/node_modules/@stdlib/array/from-scalar/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/array/from-scalar/README.md b/lib/node_modules/@stdlib/array/from-scalar/README.md index bc303a416793..fca2bdcd4e7a 100644 --- a/lib/node_modules/@stdlib/array/from-scalar/README.md +++ b/lib/node_modules/@stdlib/array/from-scalar/README.md @@ -51,10 +51,10 @@ 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 a boolean value, the default [data type][@stdlib/array/dtypes] is the [default][@stdlib/array/defaults] boolean data type. - is any other value type, the default [data type][@stdlib/array/dtypes] is `'generic'`. To explicitly specify the [data type][@stdlib/array/dtypes] of the returned array, provide a `dtype` argument.