Skip to content

Commit 21052a2

Browse files
Jaysukh-409kgryte
andauthored
feat: add boolean dtype support to ndarray/min-dtype
PR-URL: #2552 Ref: #2547 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent efecd32 commit 21052a2

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

lib/node_modules/@stdlib/ndarray/min-dtype/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ dt = minDataType( '3' );
6868

6969
## Notes
7070

71-
- The function does **not** provide precision guarantees for non-integer-valued real numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) [data type][@stdlib/ndarray/dtypes] for storing numbers having decimals.
71+
- The function does **not** provide precision guarantees for non-integer-valued numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) [data type][@stdlib/ndarray/dtypes] for storing numbers having decimals.
7272

7373
</section>
7474

lib/node_modules/@stdlib/ndarray/min-dtype/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
storing a provided scalar value.
55

66
The function does *not* provide precision guarantees for non-integer-valued
7-
real numbers. In other words, the function returns the smallest possible
7+
numbers. In other words, the function returns the smallest possible
88
floating-point (i.e., inexact) data type for storing numbers having
99
decimals.
1010

lib/node_modules/@stdlib/ndarray/min-dtype/lib/main.js

Lines changed: 7 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) 2018 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.
@@ -20,6 +20,8 @@
2020

2121
// MODULES //
2222

23+
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
24+
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
2325
var isInteger = require( '@stdlib/math/base/assert/is-integer' );
2426
var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
2527
var isComplexLike = require( '@stdlib/assert/is-complex-like' );
@@ -84,7 +86,10 @@ function minFloatDataType( value ) {
8486
* // returns 'uint8'
8587
*/
8688
function minDataType( value ) {
87-
if ( typeof value !== 'number' ) {
89+
if ( !isNumber( value ) ) {
90+
if ( isBoolean( value ) ) {
91+
return 'bool';
92+
}
8893
if ( isComplexLike( value ) ) {
8994
if ( minFloatDataType( value.re ) === 'float64' || minFloatDataType( value.im ) === 'float64' ) {
9095
return 'complex128';

lib/node_modules/@stdlib/ndarray/min-dtype/test/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 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.
@@ -177,8 +177,8 @@ tape( 'the function returns the minimum ndarray data type of the closest "kind"
177177
'float32',
178178
'generic',
179179
'generic',
180-
'generic',
181-
'generic',
180+
'bool',
181+
'bool',
182182
'generic',
183183
'complex64',
184184
'complex64',

0 commit comments

Comments
 (0)