Skip to content
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/array/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/array/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/array/dtypes] for storing numbers having decimals.

</section>

Expand Down
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/array/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
22 changes: 17 additions & 5 deletions lib/node_modules/@stdlib/array/min-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,15 +20,15 @@

/// <reference types="@stdlib/types"/>

import { RealDataType, ComplexFloatingPointDataType } from '@stdlib/types/array';
import { RealDataType, ComplexFloatingPointDataType, BooleanDataType } from '@stdlib/types/array';
import { ComplexLike } from '@stdlib/types/complex';

/**
* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value.
*
* ## 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 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 for storing numbers having decimals.
*
* @param value - scalar value
* @returns array data type
Expand All @@ -48,7 +48,7 @@ declare function minDataType( value: number ): RealDataType;
*
* ## 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 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 for storing numbers having decimals.
*
* @param value - scalar value
* @returns array data type
Expand All @@ -63,12 +63,24 @@ declare function minDataType( value: number ): RealDataType;
*/
declare function minDataType( value: ComplexLike ): ComplexFloatingPointDataType;

/**
* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value.
*
* @param value - scalar value
* @returns array data type
*
* @example
* var dt = minDataType( true );
* // returns 'bool'
*/
declare function minDataType( value: boolean ): BooleanDataType;

/**
* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value.
*
* ## 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 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 for storing numbers having decimals.
*
* @param value - scalar value
* @returns array data type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import minDataType = require( './index' );

minDataType( 2.13 ); // $ExpectType RealDataType
minDataType( z ); // $ExpectType ComplexFloatingPointDataType
minDataType( true ); // $ExpectType "bool"
minDataType( 'beep' ); // $ExpectType "generic"
}

Expand Down
9 changes: 7 additions & 2 deletions lib/node_modules/@stdlib/array/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/array/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 @@ -179,8 +179,8 @@ tape( 'the function returns the minimum array data type of the closest "kind" ne
'float32',
'generic',
'generic',
'generic',
'generic',
'bool',
'bool',
'generic',
'complex64',
'complex64',
Expand Down