Skip to content

Commit 0f0dbca

Browse files
Jaysukh-409kgryte
andauthored
feat: add boolean dtype support to ndarray/base/buffer-ctors
PR-URL: #2571 Ref: #2547 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]>
1 parent 337adbf commit 0f0dbca

File tree

5 files changed

+17
-42
lines changed

5 files changed

+17
-42
lines changed

lib/node_modules/@stdlib/ndarray/base/buffer-ctors/README.md

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2018 The Stdlib Authors.
5+
Copyright (c) 2024 The Stdlib Authors.
66
77
Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
@@ -42,30 +42,14 @@ var ctors = require( '@stdlib/ndarray/base/buffer-ctors' );
4242

4343
#### ctors( dtype )
4444

45-
Returns an ndarray data buffer constructor for a specified data type.
45+
Returns an ndarray data buffer constructor for a specified [data type][@stdlib/ndarray/dtypes].
4646

4747
```javascript
4848
var ctor = ctors( 'float64' );
4949
// returns <Function>
5050
```
5151

52-
The function returns constructors for the following data types:
53-
54-
- `binary`: binary.
55-
- `complex64`: single-precision complex floating-point numbers.
56-
- `complex128`: double-precision complex floating-point numbers.
57-
- `float32`: single-precision floating-point numbers.
58-
- `float64`: double-precision floating-point numbers.
59-
- `generic`: values of any type.
60-
- `int16`: signed 16-bit integers.
61-
- `int32`: signed 32-bit integers.
62-
- `int8`: signed 8-bit integers.
63-
- `uint16`: unsigned 16-bit integers.
64-
- `uint32`: unsigned 32-bit integers.
65-
- `uint8`: unsigned 8-bit integers.
66-
- `uint8c`: unsigned clamped 8-bit integers.
67-
68-
If provided an unknown or unsupported data type, the function returns `null`.
52+
If provided an unknown or unsupported [data type][@stdlib/ndarray/dtypes], the function returns `null`.
6953

7054
```javascript
7155
var ctor = ctors( 'float' );
@@ -97,9 +81,9 @@ var dtypes = require( '@stdlib/ndarray/dtypes' );
9781
var ctors = require( '@stdlib/ndarray/base/buffer-ctors' );
9882

9983
var DTYPES = dtypes();
84+
10085
var ctor;
10186
var i;
102-
10387
for ( i = 0; i < DTYPES.length; i++ ) {
10488
ctor = ctors( DTYPES[ i ] );
10589
console.log( ctor );
@@ -130,6 +114,8 @@ for ( i = 0; i < DTYPES.length; i++ ) {
130114

131115
<section class="links">
132116

117+
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/dtypes
118+
133119
</section>
134120

135121
<!-- /.links -->

lib/node_modules/@stdlib/ndarray/base/buffer-ctors/docs/repl.txt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@
22
{{alias}}( dtype )
33
Returns an ndarray data buffer constructor.
44

5-
The function returns constructors for the following data types:
6-
7-
- binary: binary.
8-
- complex64: single-precision complex floating-point numbers.
9-
- complex128: double-precision complex floating-point numbers.
10-
- float32: single-precision floating-point numbers.
11-
- float64: double-precision floating-point numbers.
12-
- generic: values of any type.
13-
- int16: signed 16-bit integers.
14-
- int32: signed 32-bit integers.
15-
- int8: signed 8-bit integers.
16-
- uint16: unsigned 16-bit integers.
17-
- uint32: unsigned 32-bit integers.
18-
- uint8: unsigned 8-bit integers.
19-
- uint8c: unsigned clamped 8-bit integers.
20-
215
Parameters
226
----------
237
dtype: string

lib/node_modules/@stdlib/ndarray/base/buffer-ctors/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ var dtypes = require( '@stdlib/ndarray/dtypes' );
2222
var ctors = require( './../lib' );
2323

2424
var DTYPES = dtypes();
25+
2526
var ctor;
2627
var i;
27-
2828
for ( i = 0; i < DTYPES.length; i++ ) {
2929
ctor = ctors( DTYPES[ i ] );
3030
console.log( ctor );

lib/node_modules/@stdlib/ndarray/base/buffer-ctors/lib/ctors.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ var Uint8Array = require( '@stdlib/array/uint8' );
3232
var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
3333
var Complex64Array = require( '@stdlib/array/complex64' );
3434
var Complex128Array = require( '@stdlib/array/complex128' );
35+
var BooleanArray = require( '@stdlib/array/bool' );
3536

3637

3738
// MAIN //
@@ -50,7 +51,8 @@ var ctors = {
5051
'uint8': Uint8Array,
5152
'uint8c': Uint8ClampedArray,
5253
'complex64': Complex64Array,
53-
'complex128': Complex128Array
54+
'complex128': Complex128Array,
55+
'bool': BooleanArray
5456
};
5557

5658

lib/node_modules/@stdlib/ndarray/base/buffer-ctors/test/test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ var Uint8Array = require( '@stdlib/array/uint8' );
3434
var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
3535
var Complex64Array = require( '@stdlib/array/complex64' );
3636
var Complex128Array = require( '@stdlib/array/complex128' );
37+
var BooleanArray = require( '@stdlib/array/bool' );
3738
var isFunction = require( '@stdlib/assert/is-function' );
3839
var ctors = require( './../lib' );
3940

@@ -65,7 +66,8 @@ tape( 'the function returns ndarray data buffer constructors', function test( t
6566
'uint8',
6667
'uint8c',
6768
'complex64',
68-
'complex128'
69+
'complex128',
70+
'bool'
6971
];
7072
expected = [
7173
Buffer,
@@ -80,7 +82,8 @@ tape( 'the function returns ndarray data buffer constructors', function test( t
8082
Uint8Array,
8183
Uint8ClampedArray,
8284
Complex64Array,
83-
Complex128Array
85+
Complex128Array,
86+
BooleanArray
8487
];
8588
for ( i = 0; i < dtypes.length; i++ ) {
8689
ctor = ctors( dtypes[ i ] );

0 commit comments

Comments
 (0)