From ac02a607877a6f891f86699a5f8687200d9fcad1 Mon Sep 17 00:00:00 2001 From: Jaysukh-409 Date: Fri, 12 Jul 2024 15:48:38 +0530 Subject: [PATCH 1/2] feat: add boolean dtype support to ndarray/base/buffer-ctors --- .../@stdlib/ndarray/base/buffer-ctors/README.md | 3 ++- .../@stdlib/ndarray/base/buffer-ctors/docs/repl.txt | 1 + .../@stdlib/ndarray/base/buffer-ctors/lib/ctors.js | 6 ++++-- .../@stdlib/ndarray/base/buffer-ctors/test/test.js | 9 ++++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/README.md b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/README.md index 4fe715d6cf2f..500a20cc8a32 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/README.md @@ -2,7 +2,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. @@ -52,6 +52,7 @@ var ctor = ctors( 'float64' ); The function returns constructors for the following data types: - `binary`: binary. +- `bool`: boolean values. - `complex64`: single-precision complex floating-point numbers. - `complex128`: double-precision complex floating-point numbers. - `float32`: single-precision floating-point numbers. diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/docs/repl.txt index 9c2aa1525310..0c10c8cef280 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/docs/repl.txt @@ -5,6 +5,7 @@ The function returns constructors for the following data types: - binary: binary. + - bool: boolean values. - complex64: single-precision complex floating-point numbers. - complex128: double-precision complex floating-point numbers. - float32: single-precision floating-point numbers. diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/lib/ctors.js b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/lib/ctors.js index cd81219b72a2..a8c00992c1a8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/lib/ctors.js +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/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. @@ -32,6 +32,7 @@ var Uint8Array = require( '@stdlib/array/uint8' ); var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex128Array = require( '@stdlib/array/complex128' ); +var BooleanArray = require( '@stdlib/array/bool' ); // MAIN // @@ -50,7 +51,8 @@ var ctors = { 'uint8': Uint8Array, 'uint8c': Uint8ClampedArray, 'complex64': Complex64Array, - 'complex128': Complex128Array + 'complex128': Complex128Array, + 'bool': BooleanArray }; diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/test/test.js b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/test/test.js index e2f9c80f2e94..64f86360998f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/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. @@ -34,6 +34,7 @@ var Uint8Array = require( '@stdlib/array/uint8' ); var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex128Array = require( '@stdlib/array/complex128' ); +var BooleanArray = require( '@stdlib/array/bool' ); var isFunction = require( '@stdlib/assert/is-function' ); var ctors = require( './../lib' ); @@ -65,7 +66,8 @@ tape( 'the function returns ndarray data buffer constructors', function test( t 'uint8', 'uint8c', 'complex64', - 'complex128' + 'complex128', + 'bool' ]; expected = [ Buffer, @@ -80,7 +82,8 @@ tape( 'the function returns ndarray data buffer constructors', function test( t Uint8Array, Uint8ClampedArray, Complex64Array, - Complex128Array + Complex128Array, + BooleanArray ]; for ( i = 0; i < dtypes.length; i++ ) { ctor = ctors( dtypes[ i ] ); From 8a09c2f789ba15e4a984b9f06e92ab8ac461e2e5 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 19:27:27 -0700 Subject: [PATCH 2/2] docs: reduce future maintenance burden by linking to dtypes package --- .../ndarray/base/buffer-ctors/README.md | 25 ++++--------------- .../ndarray/base/buffer-ctors/docs/repl.txt | 17 ------------- .../base/buffer-ctors/examples/index.js | 2 +- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/README.md b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/README.md index 500a20cc8a32..efa54335a2b7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/README.md @@ -42,31 +42,14 @@ var ctors = require( '@stdlib/ndarray/base/buffer-ctors' ); #### ctors( dtype ) -Returns an ndarray data buffer constructor for a specified data type. +Returns an ndarray data buffer constructor for a specified [data type][@stdlib/ndarray/dtypes]. ```javascript var ctor = ctors( 'float64' ); // returns ``` -The function returns constructors for the following data types: - -- `binary`: binary. -- `bool`: boolean values. -- `complex64`: single-precision complex floating-point numbers. -- `complex128`: double-precision complex floating-point numbers. -- `float32`: single-precision floating-point numbers. -- `float64`: double-precision floating-point numbers. -- `generic`: values of any type. -- `int16`: signed 16-bit integers. -- `int32`: signed 32-bit integers. -- `int8`: signed 8-bit integers. -- `uint16`: unsigned 16-bit integers. -- `uint32`: unsigned 32-bit integers. -- `uint8`: unsigned 8-bit integers. -- `uint8c`: unsigned clamped 8-bit integers. - -If provided an unknown or unsupported data type, the function returns `null`. +If provided an unknown or unsupported [data type][@stdlib/ndarray/dtypes], the function returns `null`. ```javascript var ctor = ctors( 'float' ); @@ -98,9 +81,9 @@ var dtypes = require( '@stdlib/ndarray/dtypes' ); var ctors = require( '@stdlib/ndarray/base/buffer-ctors' ); var DTYPES = dtypes(); + var ctor; var i; - for ( i = 0; i < DTYPES.length; i++ ) { ctor = ctors( DTYPES[ i ] ); console.log( ctor ); @@ -131,6 +114,8 @@ for ( i = 0; i < DTYPES.length; i++ ) { diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/docs/repl.txt index 0c10c8cef280..105b7dfbd044 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/docs/repl.txt @@ -2,23 +2,6 @@ {{alias}}( dtype ) Returns an ndarray data buffer constructor. - The function returns constructors for the following data types: - - - binary: binary. - - bool: boolean values. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - Parameters ---------- dtype: string diff --git a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/examples/index.js index da5b2c88916a..f04e65961030 100644 --- a/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/buffer-ctors/examples/index.js @@ -22,9 +22,9 @@ var dtypes = require( '@stdlib/ndarray/dtypes' ); var ctors = require( './../lib' ); var DTYPES = dtypes(); + var ctor; var i; - for ( i = 0; i < DTYPES.length; i++ ) { ctor = ctors( DTYPES[ i ] ); console.log( ctor );