Skip to content

Commit

Permalink
feat: add boolean dtype support in array/dtype
Browse files Browse the repository at this point in the history
PR-URL: #2306
Ref: #2304
Co-authored-by: Athan Reines <kgryte@gmail.com>
Reviewed-by: Athan Reines <kgryte@gmail.com>
  • Loading branch information
Jaysukh-409 and kgryte authored Jun 6, 2024
1 parent 1510858 commit 26681a0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
18 changes: 16 additions & 2 deletions lib/node_modules/@stdlib/array/dtype/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2021 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 All @@ -20,7 +20,7 @@

/// <reference types="@stdlib/types"/>

import { RealOrComplexTypedArray, Complex128Array, Complex64Array, DataType } from '@stdlib/types/array';
import { RealOrComplexTypedArray, Complex128Array, Complex64Array, BooleanArray, DataType } from '@stdlib/types/array';

/**
* Returns the data type of an array.
Expand Down Expand Up @@ -78,6 +78,20 @@ declare function dtype( value: Complex128Array ): 'complex128';
*/
declare function dtype( value: Complex64Array ): 'complex64';

/**
* Returns the data type of an array.
*
* @param value - input value
* @returns data type
*
* @example
* var BooleanArray = require( '@stdlib/array/bool' );
*
* var dt = dtype( new BooleanArray( [ true, false, true, false ] ) );
* // returns 'bool'
*/
declare function dtype( value: BooleanArray ): 'bool';

/**
* Returns the data type of an array.
*
Expand Down
4 changes: 3 additions & 1 deletion lib/node_modules/@stdlib/array/dtype/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2021 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 All @@ -18,6 +18,7 @@

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


Expand All @@ -36,6 +37,7 @@ import dtype = require( './index' );
dtype( new Uint16Array( 10 ) ); // $ExpectType "uint16"
dtype( new Uint8Array( 10 ) ); // $ExpectType "uint8"
dtype( new Uint8ClampedArray( 10 ) ); // $ExpectType "uint8c"
dtype( new BooleanArray( 10 ) ); // $ExpectType "bool"
dtype( [] ); // $ExpectType "generic"
}

Expand Down
5 changes: 3 additions & 2 deletions lib/node_modules/@stdlib/array/dtype/lib/ctor2dtype.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,7 +33,8 @@ var ctor2dtypes = {
'Uint8Array': 'uint8',
'Uint8ClampedArray': 'uint8c',
'Complex64Array': 'complex64',
'Complex128Array': 'complex128'
'Complex128Array': 'complex128',
'BooleanArray': 'bool'
};


Expand Down
6 changes: 4 additions & 2 deletions lib/node_modules/@stdlib/array/dtype/lib/ctors.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 @@ -31,6 +31,7 @@ var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
var Int8Array = require( '@stdlib/array/int8' );
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex128Array = require( '@stdlib/array/complex128' );
var BooleanArray = require( '@stdlib/array/bool' );


// MAIN //
Expand All @@ -47,7 +48,8 @@ var CTORS = [
Uint8Array,
Uint8ClampedArray,
Complex64Array,
Complex128Array
Complex128Array,
BooleanArray
];


Expand Down
5 changes: 3 additions & 2 deletions lib/node_modules/@stdlib/array/dtype/lib/dtypes.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 @@ -32,7 +32,8 @@ var DTYPES = [
'uint8',
'uint8c',
'complex64',
'complex128'
'complex128',
'bool'
];


Expand Down

1 comment on commit 26681a0

@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/dtype $\color{green}263/263$
$\color{green}+100.00\%$
$\color{green}13/13$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}263/263$
$\color{green}+100.00\%$

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

Please sign in to comment.