Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jul 13, 2024
1 parent 027da53 commit df336f5
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 13 deletions.
43 changes: 42 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<section class="release" id="unreleased">

## Unreleased (2024-07-12)
## Unreleased (2024-07-13)

<section class="packages">

Expand Down Expand Up @@ -1755,6 +1755,41 @@ This release closes the following issue:

<!-- /.package -->

<section class="package" id="array-min-dtype-unreleased">

#### [@stdlib/array/min-dtype](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/min-dtype)

<details>

<section class="features">

##### 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)

</section>

<!-- /.features -->

<section class="breaking-changes">

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

</section>

<!-- /.breaking-changes -->

</details>

</section>

<!-- /.package -->

<section class="package" id="array-mostly-safe-casts-unreleased">

#### [@stdlib/array/mostly-safe-casts](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/mostly-safe-casts)
Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -2395,6 +2435,7 @@ A total of 13 people contributed to this release. Thank you to the following con

<details>

- [`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)_
Expand Down
2 changes: 1 addition & 1 deletion 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 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 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
1 change: 1 addition & 0 deletions min-dtype/docs/types/test.ts
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 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 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

0 comments on commit df336f5

Please sign in to comment.