Skip to content

feat: add boolean dtype support to ndarray/min-dtype #2552

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

Merged
merged 2 commits into from
Jul 13, 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
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/ndarray/min-dtype/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ dt = minDataType( '3' );

## Notes

- 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.
- 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.

</section>

Expand Down
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/ndarray/min-dtype/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
storing a provided scalar value.

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

Expand Down
9 changes: 7 additions & 2 deletions lib/node_modules/@stdlib/ndarray/min-dtype/lib/main.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 All @@ -20,6 +20,8 @@

// MODULES //

var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
var isInteger = require( '@stdlib/math/base/assert/is-integer' );
var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
var isComplexLike = require( '@stdlib/assert/is-complex-like' );
Expand Down Expand Up @@ -84,7 +86,10 @@ function minFloatDataType( value ) {
* // returns 'uint8'
*/
function minDataType( value ) {
if ( typeof value !== 'number' ) {
if ( !isNumber( value ) ) {
if ( isBoolean( value ) ) {
return 'bool';
}
if ( isComplexLike( value ) ) {
if ( minFloatDataType( value.re ) === 'float64' || minFloatDataType( value.im ) === 'float64' ) {
return 'complex128';
Expand Down
6 changes: 3 additions & 3 deletions lib/node_modules/@stdlib/ndarray/min-dtype/test/test.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 @@ -177,8 +177,8 @@ tape( 'the function returns the minimum ndarray data type of the closest "kind"
'float32',
'generic',
'generic',
'generic',
'generic',
'bool',
'bool',
'generic',
'complex64',
'complex64',
Expand Down
Loading