From a954917c57c700b1857f6b1e9f20e552cdf5c702 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Wed, 10 Jul 2024 19:19:45 +0530 Subject: [PATCH 1/2] feat: add boolean dtype support to ndarray/min-dtype --- lib/node_modules/@stdlib/ndarray/min-dtype/lib/main.js | 6 +++++- lib/node_modules/@stdlib/ndarray/min-dtype/test/test.js | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/min-dtype/lib/main.js b/lib/node_modules/@stdlib/ndarray/min-dtype/lib/main.js index 69134740a1e6..b75770d49a23 100644 --- a/lib/node_modules/@stdlib/ndarray/min-dtype/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/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. @@ -23,6 +23,7 @@ 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' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var FLOAT32_SMALLEST_SUBNORMAL = require( '@stdlib/constants/float32/smallest-subnormal' ); // eslint-disable-line id-length @@ -84,6 +85,9 @@ function minFloatDataType( value ) { * // returns 'uint8' */ function minDataType( value ) { + if ( isBoolean( value ) ) { + return 'bool'; + } if ( typeof value !== 'number' ) { if ( isComplexLike( value ) ) { if ( minFloatDataType( value.re ) === 'float64' || minFloatDataType( value.im ) === 'float64' ) { diff --git a/lib/node_modules/@stdlib/ndarray/min-dtype/test/test.js b/lib/node_modules/@stdlib/ndarray/min-dtype/test/test.js index c998dff20ff2..c4db9c07fa37 100644 --- a/lib/node_modules/@stdlib/ndarray/min-dtype/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/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. @@ -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', From 4345a04d3c3445b9e3857875dfd588991a9d00bb Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 23:30:16 -0700 Subject: [PATCH 2/2] refactor: move conditional and update copy --- lib/node_modules/@stdlib/ndarray/min-dtype/README.md | 2 +- .../@stdlib/ndarray/min-dtype/docs/repl.txt | 2 +- .../@stdlib/ndarray/min-dtype/lib/main.js | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/min-dtype/README.md b/lib/node_modules/@stdlib/ndarray/min-dtype/README.md index cdb8b687ab2c..85a94a3151dd 100644 --- a/lib/node_modules/@stdlib/ndarray/min-dtype/README.md +++ b/lib/node_modules/@stdlib/ndarray/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/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. diff --git a/lib/node_modules/@stdlib/ndarray/min-dtype/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/min-dtype/docs/repl.txt index 96a18767fb60..aeaf4246a713 100644 --- a/lib/node_modules/@stdlib/ndarray/min-dtype/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/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/lib/node_modules/@stdlib/ndarray/min-dtype/lib/main.js b/lib/node_modules/@stdlib/ndarray/min-dtype/lib/main.js index b75770d49a23..c9fd84461f78 100644 --- a/lib/node_modules/@stdlib/ndarray/min-dtype/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/min-dtype/lib/main.js @@ -20,10 +20,11 @@ // 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' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var FLOAT32_SMALLEST_SUBNORMAL = require( '@stdlib/constants/float32/smallest-subnormal' ); // eslint-disable-line id-length @@ -85,10 +86,10 @@ function minFloatDataType( value ) { * // returns 'uint8' */ function minDataType( value ) { - if ( isBoolean( value ) ) { - return 'bool'; - } - 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';