Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add boolean datatype support in array/dtype #2306

Merged
merged 3 commits into from
Jun 6, 2024
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
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: 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 Expand Up @@ -186,7 +200,7 @@
* var dt = dtype( [ 1, 2, 3 ] );
* // returns 'generic'
*/
declare function dtype( value: Array<any> ): 'generic';

Check warning on line 203 in lib/node_modules/@stdlib/array/dtype/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected any. Specify a different type

/**
* Returns the data type of an array.
Expand All @@ -205,7 +219,7 @@
* var dt = dtype( 'beep' );
* // returns null
*/
declare function dtype( value: Array<any> | RealOrComplexTypedArray ): DataType | null;

Check warning on line 222 in lib/node_modules/@stdlib/array/dtype/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected any. Specify a different type


// EXPORTS //
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
Loading