Skip to content

Commit ca687d6

Browse files
Jaysukh-409kgryte
andauthored
feat: add boolean dtype support to ndarray/safe-casts
PR-URL: #2507 Ref: #2500 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent fc67e61 commit ca687d6

File tree

3 files changed

+48
-23
lines changed

3 files changed

+48
-23
lines changed

lib/node_modules/@stdlib/ndarray/safe-casts/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,12 @@ var out = safeCasts( 'foo' );
9393
var dtypes = require( '@stdlib/ndarray/dtypes' );
9494
var safeCasts = require( '@stdlib/ndarray/safe-casts' );
9595

96-
var DTYPES;
97-
var list;
98-
var i;
99-
10096
// Get the list of supported ndarray data types:
101-
DTYPES = dtypes();
97+
var DTYPES = dtypes();
10298

10399
// Print the list of ndarray data types to which a data type can be safely cast...
100+
var list;
101+
var i;
104102
for ( i = 0; i < DTYPES.length; i++ ) {
105103
list = safeCasts( DTYPES[ i ] );
106104
console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) );

lib/node_modules/@stdlib/ndarray/safe-casts/examples/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
var dtypes = require( '@stdlib/ndarray/dtypes' );
2222
var safeCasts = require( './../lib' );
2323

24-
var DTYPES;
25-
var list;
26-
var i;
27-
2824
// Get the list of supported ndarray data types:
29-
DTYPES = dtypes();
25+
var DTYPES = dtypes();
3026

3127
// Print the list of ndarray data types to which a data type can be safely cast...
28+
var list;
29+
var i;
3230
for ( i = 0; i < DTYPES.length; i++ ) {
3331
list = safeCasts( DTYPES[ i ] );
3432
console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) );

lib/node_modules/@stdlib/ndarray/safe-casts/lib/safe_casts.json

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"complex128": 1,
1313
"complex64": 0,
1414
"binary": 0,
15-
"generic": 1
15+
"generic": 1,
16+
"bool": 0
1617
},
1718
"float32": {
1819
"float64": 1,
@@ -27,7 +28,8 @@
2728
"complex128": 1,
2829
"complex64": 1,
2930
"binary": 0,
30-
"generic": 1
31+
"generic": 1,
32+
"bool": 0
3133
},
3234
"int32": {
3335
"float64": 1,
@@ -42,7 +44,8 @@
4244
"complex128": 1,
4345
"complex64": 0,
4446
"binary": 0,
45-
"generic": 1
47+
"generic": 1,
48+
"bool": 0
4649
},
4750
"int16": {
4851
"float64": 1,
@@ -57,7 +60,8 @@
5760
"complex128": 1,
5861
"complex64": 1,
5962
"binary": 0,
60-
"generic": 1
63+
"generic": 1,
64+
"bool": 0
6165
},
6266
"int8": {
6367
"float64": 1,
@@ -72,7 +76,8 @@
7276
"complex128": 1,
7377
"complex64": 1,
7478
"binary": 0,
75-
"generic": 1
79+
"generic": 1,
80+
"bool": 0
7681
},
7782
"uint32": {
7883
"float64": 1,
@@ -87,7 +92,8 @@
8792
"complex128": 1,
8893
"complex64": 0,
8994
"binary": 0,
90-
"generic": 1
95+
"generic": 1,
96+
"bool": 0
9197
},
9298
"uint16": {
9399
"float64": 1,
@@ -102,7 +108,8 @@
102108
"complex128": 1,
103109
"complex64": 1,
104110
"binary": 0,
105-
"generic": 1
111+
"generic": 1,
112+
"bool": 0
106113
},
107114
"uint8": {
108115
"float64": 1,
@@ -117,7 +124,8 @@
117124
"complex128": 1,
118125
"complex64": 1,
119126
"binary": 0,
120-
"generic": 1
127+
"generic": 1,
128+
"bool": 0
121129
},
122130
"uint8c": {
123131
"float64": 1,
@@ -132,7 +140,8 @@
132140
"complex128": 1,
133141
"complex64": 1,
134142
"binary": 0,
135-
"generic": 1
143+
"generic": 1,
144+
"bool": 0
136145
},
137146
"complex128": {
138147
"float64": 0,
@@ -147,7 +156,8 @@
147156
"complex128": 1,
148157
"complex64": 0,
149158
"binary": 0,
150-
"generic": 1
159+
"generic": 1,
160+
"bool": 0
151161
},
152162
"complex64": {
153163
"float64": 0,
@@ -162,7 +172,8 @@
162172
"complex128": 1,
163173
"complex64": 1,
164174
"binary": 0,
165-
"generic": 1
175+
"generic": 1,
176+
"bool": 0
166177
},
167178
"generic": {
168179
"float64": 0,
@@ -177,7 +188,8 @@
177188
"complex128": 0,
178189
"complex64": 0,
179190
"binary": 0,
180-
"generic": 1
191+
"generic": 1,
192+
"bool": 0
181193
},
182194
"binary": {
183195
"float64": 0,
@@ -192,6 +204,23 @@
192204
"complex128": 0,
193205
"complex64": 0,
194206
"binary": 1,
195-
"generic": 0
207+
"generic": 0,
208+
"bool": 0
209+
},
210+
"bool": {
211+
"float64": 0,
212+
"float32": 0,
213+
"int32": 0,
214+
"int16": 0,
215+
"int8": 0,
216+
"uint32": 0,
217+
"uint16": 0,
218+
"uint8": 0,
219+
"uint8c": 0,
220+
"complex128": 0,
221+
"complex64": 0,
222+
"binary": 0,
223+
"generic": 1,
224+
"bool": 1
196225
}
197226
}

0 commit comments

Comments
 (0)