Skip to content

Commit f1b5bc9

Browse files
Jaysukh-409kgryte
andauthored
feat: add boolean dtype support to strided/dtypes
PR-URL: #2508 Ref: #2500 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 04b3803 commit f1b5bc9

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed

lib/node_modules/@stdlib/strided/dtypes/README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2020 The Stdlib Authors.
5+
Copyright (c) 2024 The Stdlib Authors.
66
77
Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
@@ -46,12 +46,13 @@ Returns a list of strided array data types.
4646

4747
```javascript
4848
var out = dtypes();
49-
// returns [ 'binary', 'complex64', 'complex128', 'float32', 'float64', 'generic', 'int16', 'int32', 'int8', 'uint16', 'uint32', 'uint8', 'uint8c' ]
49+
// e.g., returns [ 'binary', 'bool', 'complex64', ... ]
5050
```
5151

52-
The output `array` contains the following data types:
52+
The output array contains the following data types:
5353

5454
- `binary`: binary.
55+
- `bool`: boolean values.
5556
- `complex64`: single-precision complex floating-point numbers.
5657
- `complex128`: double-precision complex floating-point numbers.
5758
- `float32`: single-precision floating-point numbers.
@@ -86,17 +87,12 @@ The output `array` contains the following data types:
8687
<!-- eslint no-undef: "error" -->
8788

8889
```javascript
89-
var indexOf = require( '@stdlib/utils/index-of' );
90+
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
9091
var dtypes = require( '@stdlib/strided/dtypes' );
9192

92-
var DTYPES = dtypes();
93-
var bool;
93+
var isdtype = contains( dtypes() );
9494

95-
function isdtype( str ) {
96-
return ( indexOf( DTYPES, str ) >= 0 );
97-
}
98-
99-
bool = isdtype( 'float64' );
95+
var bool = isdtype( 'float64' );
10096
// returns true
10197

10298
bool = isdtype( 'int16' );

lib/node_modules/@stdlib/strided/dtypes/docs/repl.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
The output array contains the following data types:
66

77
- binary: binary.
8+
- bool: boolean values.
89
- complex64: single-precision complex floating-point numbers.
910
- complex128: double-precision complex floating-point numbers.
1011
- float32: single-precision floating-point numbers.

lib/node_modules/@stdlib/strided/dtypes/examples/index.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,12 @@
1818

1919
'use strict';
2020

21-
var indexOf = require( '@stdlib/utils/index-of' );
21+
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
2222
var dtypes = require( './../lib' );
2323

24-
var DTYPES = dtypes();
25-
var bool;
24+
var isdtype = contains( dtypes() );
2625

27-
function isdtype( str ) {
28-
return ( indexOf( DTYPES, str ) >= 0 );
29-
}
30-
31-
bool = isdtype( 'float64' );
26+
var bool = isdtype( 'float64' );
3227
console.log( bool );
3328
// => true
3429

lib/node_modules/@stdlib/strided/dtypes/lib/dtypes.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
2-
"binary",
2+
"binary",
3+
"bool",
34
"complex64",
45
"complex128",
56
"float32",

lib/node_modules/@stdlib/strided/dtypes/test/test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -43,7 +43,9 @@ var DTYPES = [
4343
'float64',
4444

4545
'complex64',
46-
'complex128'
46+
'complex128',
47+
48+
'bool'
4749
];
4850

4951

@@ -61,6 +63,7 @@ tape( 'the function returns a list of strided array data type strings', function
6163

6264
expected = [
6365
'binary',
66+
'bool',
6467
'complex64',
6568
'complex128',
6669
'float32',

0 commit comments

Comments
 (0)