diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b01e438..00cd5a97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@
-## Unreleased (2024-07-12) +## Unreleased (2024-07-13)
@@ -1755,6 +1755,41 @@ This release closes the following issue: +
+ +#### [@stdlib/array/min-dtype](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/min-dtype) + +
+ +
+ +##### Features + +- [`66dce03`](https://github.com/stdlib-js/stdlib/commit/66dce034698fdbd71248cad9c7d277ac97cdf0ae) - add boolean dtype support to `array/min-dtype` [(#2556)](https://github.com/stdlib-js/stdlib/pull/2556) + +
+ + + +
+ +##### BREAKING CHANGES + +- [`66dce03`](https://github.com/stdlib-js/stdlib/commit/66dce034698fdbd71248cad9c7d277ac97cdf0ae): add boolean dtype support to `array/min-dtype` +- [`66dce03`](https://github.com/stdlib-js/stdlib/commit/66dce034698fdbd71248cad9c7d277ac97cdf0ae): return \"bool\" when provided a boolean + + - To migrate, users explicitly handle \"bool\" return values. If \"generic\" is still desired, users should consolidate accordingly. + +
+ + + +
+ +
+ + +
#### [@stdlib/array/mostly-safe-casts](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/mostly-safe-casts) @@ -2326,6 +2361,11 @@ This release closes the following issue: ### BREAKING CHANGES +- [`66dce03`](https://github.com/stdlib-js/stdlib/commit/66dce034698fdbd71248cad9c7d277ac97cdf0ae): add boolean dtype support to `array/min-dtype` +- [`66dce03`](https://github.com/stdlib-js/stdlib/commit/66dce034698fdbd71248cad9c7d277ac97cdf0ae): return \"bool\" when provided a boolean + + - To migrate, users explicitly handle \"bool\" return values. If \"generic\" is still desired, users should consolidate accordingly. + - [`fdb5d94`](https://github.com/stdlib-js/stdlib/commit/fdb5d94eee5fc019bc358d799025cb2b5966d820): add support for additional modes - [`fdb5d94`](https://github.com/stdlib-js/stdlib/commit/fdb5d94eee5fc019bc358d799025cb2b5966d820): rename 'throw' mode to 'strict' @@ -2395,6 +2435,7 @@ A total of 13 people contributed to this release. Thank you to the following con
+- [`66dce03`](https://github.com/stdlib-js/stdlib/commit/66dce034698fdbd71248cad9c7d277ac97cdf0ae) - **feat:** add boolean dtype support to `array/min-dtype` [(#2556)](https://github.com/stdlib-js/stdlib/pull/2556) _(by Jaysukh Makvana, Athan Reines)_ - [`5a66b4b`](https://github.com/stdlib-js/stdlib/commit/5a66b4bb677cdbc4706811ea9f776343297c9f87) - **feat:** add `join` and `toString` methods to `array/bool` [(#2557)](https://github.com/stdlib-js/stdlib/pull/2557) _(by Jaysukh Makvana, Athan Reines)_ - [`659f752`](https://github.com/stdlib-js/stdlib/commit/659f752db18317bf5fc237fdbcad0d74b61e1ed9) - **style:** add missing spaces _(by Philipp Burckhardt)_ - [`a78f7d1`](https://github.com/stdlib-js/stdlib/commit/a78f7d1b859b6b1d7b0bc0ee4daf76789e3e0910) - **style:** add missing spaces _(by Philipp Burckhardt)_ diff --git a/min-dtype/README.md b/min-dtype/README.md index 5c91277c..f1b5f828 100644 --- a/min-dtype/README.md +++ b/min-dtype/README.md @@ -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.
diff --git a/min-dtype/docs/repl.txt b/min-dtype/docs/repl.txt index bc72a8d1..56df9cf1 100644 --- a/min-dtype/docs/repl.txt +++ b/min-dtype/docs/repl.txt @@ -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. diff --git a/min-dtype/docs/types/index.d.ts b/min-dtype/docs/types/index.d.ts index 814b932b..e2c68295 100644 --- a/min-dtype/docs/types/index.d.ts +++ b/min-dtype/docs/types/index.d.ts @@ -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. @@ -20,7 +20,7 @@ /// -import { RealDataType, ComplexFloatingPointDataType } from '@stdlib/types/array'; +import { RealDataType, ComplexFloatingPointDataType, BooleanDataType } from '@stdlib/types/array'; import { ComplexLike } from '@stdlib/types/complex'; /** @@ -28,7 +28,7 @@ import { ComplexLike } from '@stdlib/types/complex'; * * ## 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 @@ -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 @@ -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 diff --git a/min-dtype/docs/types/test.ts b/min-dtype/docs/types/test.ts index 2957567d..79214d61 100644 --- a/min-dtype/docs/types/test.ts +++ b/min-dtype/docs/types/test.ts @@ -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" } diff --git a/min-dtype/lib/main.js b/min-dtype/lib/main.js index bc8af625..5342fcaf 100644 --- a/min-dtype/lib/main.js +++ b/min-dtype/lib/main.js @@ -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. @@ -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' ); @@ -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'; diff --git a/min-dtype/test/test.js b/min-dtype/test/test.js index 3075eb88..7dab65e1 100644 --- a/min-dtype/test/test.js +++ b/min-dtype/test/test.js @@ -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. @@ -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',