Skip to content

Commit 1b846f1

Browse files
committed
Auto-generated commit
1 parent b2f6c57 commit 1b846f1

File tree

11 files changed

+120
-51
lines changed

11 files changed

+120
-51
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,28 @@
7777

7878
<!-- /.package -->
7979

80+
<section class="package" id="ndarray-base-buffer-unreleased">
81+
82+
#### [@stdlib/ndarray/base/buffer](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer)
83+
84+
<details>
85+
86+
<section class="features">
87+
88+
##### Features
89+
90+
- [`fa118f2`](https://github.com/stdlib-js/stdlib/commit/fa118f279848e1c85ea6e5cf9799f3089649214c) - add boolean dtype support to `ndarray/base/buffer` [(#2574)](https://github.com/stdlib-js/stdlib/pull/2574)
91+
92+
</section>
93+
94+
<!-- /.features -->
95+
96+
</details>
97+
98+
</section>
99+
100+
<!-- /.package -->
101+
80102
<section class="package" id="ndarray-base-buffer-ctors-unreleased">
81103

82104
#### [@stdlib/ndarray/base/buffer-ctors](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer-ctors)
@@ -463,6 +485,7 @@ A total of 3 people contributed to this release. Thank you to the following cont
463485

464486
<details>
465487

488+
- [`fa118f2`](https://github.com/stdlib-js/stdlib/commit/fa118f279848e1c85ea6e5cf9799f3089649214c) - **feat:** add boolean dtype support to `ndarray/base/buffer` [(#2574)](https://github.com/stdlib-js/stdlib/pull/2574) _(by Jaysukh Makvana, Athan Reines)_
466489
- [`e92152b`](https://github.com/stdlib-js/stdlib/commit/e92152baba61ab358640cba9d0506d75123a5f60) - **feat:** add boolean dtype support to `ndarray/defaults` [(#2551)](https://github.com/stdlib-js/stdlib/pull/2551) _(by Jaysukh Makvana, Athan Reines)_
467490
- [`16e0808`](https://github.com/stdlib-js/stdlib/commit/16e0808004b7bd4f16eea7eced5229ee1120b577) - **feat:** add boolean dtype support to `ndarray/dtypes` [(#2550)](https://github.com/stdlib-js/stdlib/pull/2550) _(by Jaysukh Makvana, Athan Reines)_
468491
- [`21052a2`](https://github.com/stdlib-js/stdlib/commit/21052a211289b86b0e8a2e1f43a4d4c5b2379ffb) - **feat:** add boolean dtype support to `ndarray/min-dtype` [(#2552)](https://github.com/stdlib-js/stdlib/pull/2552) _(by Jaysukh Makvana, Athan Reines)_

base/buffer/README.md

Lines changed: 11 additions & 21 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.
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# Contiguous Data Buffer
2222

23-
> Create a zero-filled contiguous linear ndarray data buffer.
23+
> Create a contiguous linear ndarray data buffer.
2424
2525
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
2626

@@ -42,30 +42,14 @@ var buffer = require( '@stdlib/ndarray/base/buffer' );
4242

4343
#### buffer( dtype, size )
4444

45-
Returns a zero-filled contiguous linear ndarray data buffer.
45+
Returns a contiguous linear ndarray data buffer having a specified [data type][@stdlib/ndarray/dtypes].
4646

4747
```javascript
4848
var buf = buffer( 'float64', 3 );
4949
// returns <Float64Array>[ 0.0, 0.0, 0.0 ]
5050
```
5151

52-
The function supports 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 buf = buffer( 'float', 3 );
@@ -80,6 +64,10 @@ var buf = buffer( 'float', 3 );
8064

8165
<section class="notes">
8266

67+
## Notes
68+
69+
- When provided a numeric [data type][@stdlib/ndarray/dtypes], "generic", or "binary", the function returns a zero-filled contiguous linear ndarray data buffer.
70+
8371
</section>
8472

8573
<!-- /.notes -->
@@ -97,9 +85,9 @@ var dtypes = require( '@stdlib/ndarray/dtypes' );
9785
var buffer = require( '@stdlib/ndarray/base/buffer' );
9886

9987
var DTYPES = dtypes();
88+
10089
var buf;
10190
var i;
102-
10391
for ( i = 0; i < DTYPES.length; i++ ) {
10492
buf = buffer( DTYPES[ i ], 10 );
10593
console.log( buf );
@@ -130,6 +118,8 @@ for ( i = 0; i < DTYPES.length; i++ ) {
130118

131119
<section class="links">
132120

121+
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray/tree/main/dtypes
122+
133123
</section>
134124

135125
<!-- /.links -->

base/buffer/benchmark/benchmark.js

Lines changed: 58 additions & 1 deletion
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.
@@ -47,6 +47,63 @@ bench( pkg+':dtype=binary', function benchmark( b ) {
4747
b.end();
4848
});
4949

50+
bench( pkg+':dtype=bool', function benchmark( b ) {
51+
var out;
52+
var i;
53+
54+
b.tic();
55+
for ( i = 0; i < b.iterations; i++ ) {
56+
out = buffer( 'bool', 10 );
57+
if ( out.length !== 10 ) {
58+
b.fail( 'should have length 10' );
59+
}
60+
}
61+
b.toc();
62+
if ( !isCollection( out ) ) {
63+
b.fail( 'should return an array-like object' );
64+
}
65+
b.pass( 'benchmark finished' );
66+
b.end();
67+
});
68+
69+
bench( pkg+':dtype=complex64', function benchmark( b ) {
70+
var out;
71+
var i;
72+
73+
b.tic();
74+
for ( i = 0; i < b.iterations; i++ ) {
75+
out = buffer( 'complex64', 10 );
76+
if ( out.length !== 10 ) {
77+
b.fail( 'should have length 10' );
78+
}
79+
}
80+
b.toc();
81+
if ( !isCollection( out ) ) {
82+
b.fail( 'should return an array-like object' );
83+
}
84+
b.pass( 'benchmark finished' );
85+
b.end();
86+
});
87+
88+
bench( pkg+':dtype=complex128', function benchmark( b ) {
89+
var out;
90+
var i;
91+
92+
b.tic();
93+
for ( i = 0; i < b.iterations; i++ ) {
94+
out = buffer( 'complex128', 10 );
95+
if ( out.length !== 10 ) {
96+
b.fail( 'should have length 10' );
97+
}
98+
}
99+
b.toc();
100+
if ( !isCollection( out ) ) {
101+
b.fail( 'should return an array-like object' );
102+
}
103+
b.pass( 'benchmark finished' );
104+
b.end();
105+
});
106+
50107
bench( pkg+':dtype=float64', function benchmark( b ) {
51108
var out;
52109
var i;

base/buffer/benchmark/benchmark.length.js

Lines changed: 10 additions & 1 deletion
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.
@@ -90,6 +90,15 @@ function main() {
9090
f = createBenchmark( 'binary', len );
9191
bench( pkg+':len='+len+',dtype=binary', f );
9292

93+
f = createBenchmark( 'bool', len );
94+
bench( pkg+':len='+len+',dtype=bool', f );
95+
96+
f = createBenchmark( 'complex64', len );
97+
bench( pkg+':len='+len+',dtype=complex64', f );
98+
99+
f = createBenchmark( 'complex128', len );
100+
bench( pkg+':len='+len+',dtype=complex128', f );
101+
93102
f = createBenchmark( 'float64', len );
94103
bench( pkg+':len='+len+',dtype=float64', f );
95104

base/buffer/docs/repl.txt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11

22
{{alias}}( dtype, size )
3-
Returns a zero-filled contiguous linear ndarray data buffer.
4-
5-
The function supports 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.
3+
Returns a contiguous linear ndarray data buffer.
204

215
Parameters
226
----------

base/buffer/docs/types/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
/// <reference types="node"/>
2323

2424
import { Buffer } from 'buffer';
25-
import { TypedArray } from '@stdlib/types/array';
25+
import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array';
2626
import { DataType } from '@stdlib/types/ndarray';
2727

2828
/**
2929
* Array or typed array.
3030
*/
31-
type ArrayOrBufferOrTypedArray = Array<any> | TypedArray | Buffer | null;
31+
type ArrayOrBufferOrTypedArray = Array<any> | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null;
3232

3333
/**
34-
* Returns a zero-filled contiguous linear ndarray data buffer.
34+
* Returns a contiguous linear ndarray data buffer.
3535
*
3636
* @param dtype - data type
3737
* @param size - buffer size

base/buffer/examples/index.js

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

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

base/buffer/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Create a zero-filled contiguous linear ndarray data buffer.
22+
* Create a contiguous linear ndarray data buffer.
2323
*
2424
* @module @stdlib/ndarray/base/buffer
2525
*

base/buffer/lib/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ function binary( size ) {
5757
}
5858

5959
/**
60-
* Returns a zero-filled typed array.
60+
* Returns a typed array.
6161
*
6262
* @private
6363
* @param {string} dtype - data type
6464
* @param {NonNegativeInteger} size - buffer size
65-
* @returns {(TypedArray|null)} zero-filled typed array
65+
* @returns {(TypedArray|null)} typed array
6666
*/
6767
function typedarray( dtype, size ) {
6868
var ctor = bufferCtors( dtype );
@@ -76,7 +76,7 @@ function typedarray( dtype, size ) {
7676
// MAIN //
7777

7878
/**
79-
* Returns a zero-filled contiguous linear ndarray data buffer.
79+
* Returns a contiguous linear ndarray data buffer.
8080
*
8181
* @param {string} dtype - data type
8282
* @param {NonNegativeInteger} size - buffer size

base/buffer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stdlib/ndarray/base/buffer",
33
"version": "0.0.0",
4-
"description": "Create a zero-filled contiguous linear ndarray data buffer.",
4+
"description": "Create a contiguous linear ndarray data buffer.",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",

base/buffer/test/test.js

Lines changed: 8 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.
@@ -33,6 +33,7 @@ var Uint8Array = require( '@stdlib/array/uint8' );
3333
var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
3434
var Complex64Array = require( '@stdlib/array/complex64' );
3535
var Complex128Array = require( '@stdlib/array/complex128' );
36+
var BooleanArray = require( '@stdlib/array/bool' );
3637
var isBuffer = require( '@stdlib/assert/is-buffer' );
3738
var isArray = require( '@stdlib/assert/is-array' );
3839
var isFloat64Array = require( '@stdlib/assert/is-float64array' );
@@ -46,6 +47,7 @@ var isUint8Array = require( '@stdlib/assert/is-uint8array' );
4647
var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' );
4748
var isComplex64Array = require( '@stdlib/assert/is-complex64array' );
4849
var isComplex128Array = require( '@stdlib/assert/is-complex128array' );
50+
var isBooleanArray = require( '@stdlib/assert/is-booleanarray' );
4951
var buffer = require( './../lib' );
5052

5153

@@ -57,7 +59,7 @@ tape( 'main export is a function', function test( t ) {
5759
t.end();
5860
});
5961

60-
tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) {
62+
tape( 'the function returns contiguous ndarray data buffers', function test( t ) {
6163
var expected;
6264
var dtypes;
6365
var vals;
@@ -67,6 +69,7 @@ tape( 'the function returns zero-filled contiguous ndarray data buffers', functi
6769

6870
dtypes = [
6971
'binary',
72+
'bool',
7073
'complex64',
7174
'complex128',
7275
'float64',
@@ -83,6 +86,7 @@ tape( 'the function returns zero-filled contiguous ndarray data buffers', functi
8386
vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
8487
expected = [
8588
[ array2buffer( vals ), isBuffer ],
89+
[ new BooleanArray( vals ), isBooleanArray ],
8690
[ new Complex64Array( vals ), isComplex64Array ],
8791
[ new Complex128Array( vals ), isComplex128Array ],
8892
[ new Float64Array( vals ), isFloat64Array ],
@@ -115,6 +119,7 @@ tape( 'the function returns ndarray data buffers (large allocations)', function
115119

116120
dtypes = [
117121
'binary',
122+
'bool',
118123
'complex64',
119124
'complex128',
120125
'float64',
@@ -134,6 +139,7 @@ tape( 'the function returns ndarray data buffers (large allocations)', function
134139
}
135140
expected = [
136141
isBuffer,
142+
isBooleanArray,
137143
isComplex64Array,
138144
isComplex128Array,
139145
isFloat64Array,

0 commit comments

Comments
 (0)