From 22c58b8615bafcf8ae35f8835829bc1ccd6df22c Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Fri, 12 Jul 2024 15:53:45 +0530 Subject: [PATCH 1/2] feat: add boolean dtype support to ndarray/base/buffer-dtype --- .../@stdlib/ndarray/base/buffer-dtype/lib/ctor2dtype.js | 5 +++-- .../@stdlib/ndarray/base/buffer-dtype/lib/ctors.js | 6 ++++-- .../@stdlib/ndarray/base/buffer-dtype/lib/dtypes.js | 5 +++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/ctor2dtype.js b/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/ctor2dtype.js index a4880ecdc564..9bb96d797c32 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/ctor2dtype.js +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/ctor2dtype.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. @@ -35,7 +35,8 @@ var dtypes = { 'Uint8Array': 'uint8', 'Uint8ClampedArray': 'uint8c', 'Complex64Array': 'complex64', - 'Complex128Array': 'complex128' + 'Complex128Array': 'complex128', + 'BooleanArray': 'bool' }; diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/ctors.js b/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/ctors.js index c476f74d80bc..5a7a39504102 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/ctors.js +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/ctors.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. @@ -31,6 +31,7 @@ var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); var Int8Array = require( '@stdlib/array/int8' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex128Array = require( '@stdlib/array/complex128' ); +var BooleanArray = require( '@stdlib/array/bool' ); // MAIN // @@ -47,7 +48,8 @@ var CTORS = [ Uint8Array, Uint8ClampedArray, Complex64Array, - Complex128Array + Complex128Array, + BooleanArray ]; diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/dtypes.js b/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/dtypes.js index 1af257ec33d3..eb3d0b742818 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/dtypes.js +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/lib/dtypes.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. @@ -32,7 +32,8 @@ var DTYPES = [ 'uint8', 'uint8c', 'complex64', - 'complex128' + 'complex128', + 'bool' ]; From fb0a51d3be44b976898e7bf06dd5ea7ff16f191b Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 22:50:04 -0700 Subject: [PATCH 2/2] docs: update examples --- .../@stdlib/ndarray/base/buffer-dtype/README.md | 15 ++++++--------- .../ndarray/base/buffer-dtype/examples/index.js | 15 ++++++--------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/README.md b/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/README.md index 1cc5b0c0ad90..42f687dceb00 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/README.md @@ -85,20 +85,17 @@ var bufferCtors = require( '@stdlib/ndarray/base/buffer-ctors' ); var isFunction = require( '@stdlib/assert/is-function' ); var dtype = require( '@stdlib/ndarray/base/buffer-dtype' ); -var DTYPES; -var ctor; -var buf; -var len; -var dt; -var i; - // Get a list of supported ndarray buffer data types: -DTYPES = dtypes(); +var DTYPES = dtypes(); // Buffer length: -len = 10; +var len = 10; // For each supported data type, create a buffer and confirm its data type... +var ctor; +var buf; +var dt; +var i; for ( i = 0; i < DTYPES.length; i++ ) { ctor = bufferCtors( DTYPES[ i ] ); if ( DTYPES[ i ] === 'binary' && isFunction( ctor.alloc ) ) { diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/examples/index.js index 460826b8e0d9..203fe75afa49 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-dtype/examples/index.js @@ -23,20 +23,17 @@ var bufferCtors = require( '@stdlib/ndarray/base/buffer-ctors' ); var isFunction = require( '@stdlib/assert/is-function' ); var dtype = require( './../lib' ); -var DTYPES; -var ctor; -var buf; -var len; -var dt; -var i; - // Get a list of supported ndarray buffer data types: -DTYPES = dtypes(); +var DTYPES = dtypes(); // Buffer length: -len = 10; +var len = 10; // For each supported data type, create a buffer and confirm its data type... +var ctor; +var buf; +var dt; +var i; for ( i = 0; i < DTYPES.length; i++ ) { ctor = bufferCtors( DTYPES[ i ] ); if ( DTYPES[ i ] === 'binary' && isFunction( ctor.alloc ) ) {