Skip to content

Commit

Permalink
feat: add boolean dtype support in array/ctors
Browse files Browse the repository at this point in the history
PR-URL: #2308
Ref: #2304
Reviewed-by: Athan Reines <[email protected]>
  • Loading branch information
Jaysukh-409 authored Jun 6, 2024
1 parent 50e2775 commit 1510858
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/node_modules/@stdlib/array/ctors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@license Apache-2.0
Copyright (c) 2018 The Stdlib Authors.
Copyright (c) 2024 The Stdlib Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -55,6 +55,7 @@ The function returns constructors for the following data types:
- `float64`: double-precision floating-point numbers.
- `complex64`: single-precision complex floating-point numbers.
- `complex128`: double-precision complex floating-point numbers.
- `bool`: boolean values.
- `generic`: values of any type.
- `int16`: signed 16-bit integers.
- `int32`: signed 32-bit integers.
Expand Down
1 change: 1 addition & 0 deletions lib/node_modules/@stdlib/array/ctors/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- float64: double-precision floating-point numbers.
- complex64: single-precision complex floating-point numbers.
- complex128: double-precision complex floating-point numbers.
- bool: boolean values.
- generic: values of any type.
- int16: signed 16-bit integers.
- int32: signed 32-bit integers.
Expand Down
13 changes: 13 additions & 0 deletions lib/node_modules/@stdlib/array/ctors/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import Complex128Array = require( '@stdlib/array/complex128' );
import Complex64Array = require( '@stdlib/array/complex64' );
import BooleanArray = require( '@stdlib/array/bool' );

/**
* Returns a `Float64Array` constructor.
Expand Down Expand Up @@ -69,6 +70,18 @@ declare function ctors( dtype: 'complex128' ): typeof Complex128Array;
*/
declare function ctors( dtype: 'complex64' ): typeof Complex64Array;

/**
* Returns a `BooleanArray` constructor.
*
* @param dtype - data type
* @returns constructor
*
* @example
* var ctor = ctors( 'bool' );
* // returns <Function>
*/
declare function ctors( dtype: 'bool' ): typeof BooleanArray;

/**
* Returns an `Int32Array` constructor.
*
Expand Down
1 change: 1 addition & 0 deletions lib/node_modules/@stdlib/array/ctors/docs/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import ctors = require( './index' );
ctors( 'float32' ); // $ExpectType Float32ArrayConstructor
ctors( 'complex128' ); // $ExpectType Complex128ArrayConstructor
ctors( 'complex64' ); // $ExpectType Complex64ArrayConstructor
ctors( 'bool' ); // $ExpectType BooleanArrayConstructor
ctors( 'int32' ); // $ExpectType Int32ArrayConstructor
ctors( 'int16' ); // $ExpectType Int16ArrayConstructor
ctors( 'int8' ); // $ExpectType Int8ArrayConstructor
Expand Down
4 changes: 3 additions & 1 deletion lib/node_modules/@stdlib/array/ctors/lib/ctors.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var Uint8Array = require( '@stdlib/array/uint8' );
var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex128Array = require( '@stdlib/array/complex128' );
var BooleanArray = require( '@stdlib/array/bool' );


// MAIN //
Expand All @@ -48,7 +49,8 @@ var ctors = {
'uint8': Uint8Array,
'uint8c': Uint8ClampedArray,
'complex64': Complex64Array,
'complex128': Complex128Array
'complex128': Complex128Array,
'bool': BooleanArray
};


Expand Down
9 changes: 6 additions & 3 deletions lib/node_modules/@stdlib/array/ctors/test/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,7 @@ var Uint8Array = require( '@stdlib/array/uint8' );
var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex128Array = require( '@stdlib/array/complex128' );
var BooleanArray = require( '@stdlib/array/bool' );
var isFunction = require( '@stdlib/assert/is-function' );
var ctors = require( './../lib' );

Expand Down Expand Up @@ -63,7 +64,8 @@ tape( 'the function returns array constructors', function test( t ) {
'uint8',
'uint8c',
'complex64',
'complex128'
'complex128',
'bool'
];
expected = [
Float64Array,
Expand All @@ -77,7 +79,8 @@ tape( 'the function returns array constructors', function test( t ) {
Uint8Array,
Uint8ClampedArray,
Complex64Array,
Complex128Array
Complex128Array,
BooleanArray
];
for ( i = 0; i < dtypes.length; i++ ) {
ctor = ctors( dtypes[ i ] );
Expand Down

1 comment on commit 1510858

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
array/ctors $\color{green}151/151$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}151/151$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.