Skip to content

Commit e0680c5

Browse files
committed
Auto-generated commit
1 parent 95e6ef9 commit e0680c5

10 files changed

+150
-53
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,7 @@ This release closes the following issue:
15081508

15091509
##### Features
15101510

1511+
- [`d4815b6`](https://github.com/stdlib-js/stdlib/commit/d4815b6becd6231209dfdf39808a0014bcf24b84) - add boolean dtype support to `array/empty` [(#2459)](https://github.com/stdlib-js/stdlib/pull/2459)
15111512
- [`819d2e4`](https://github.com/stdlib-js/stdlib/commit/819d2e407146d4dcc17f8bab53b591b3d573f8a1) - add data type maps and replace use of overloads [(#1317)](https://github.com/stdlib-js/stdlib/pull/1317)
15121513

15131514
</section>
@@ -2284,6 +2285,7 @@ A total of 13 people contributed to this release. Thank you to the following con
22842285

22852286
<details>
22862287

2288+
- [`d4815b6`](https://github.com/stdlib-js/stdlib/commit/d4815b6becd6231209dfdf39808a0014bcf24b84) - **feat:** add boolean dtype support to `array/empty` [(#2459)](https://github.com/stdlib-js/stdlib/pull/2459) _(by Jaysukh Makvana, Athan Reines)_
22872289
- [`bddc8fa`](https://github.com/stdlib-js/stdlib/commit/bddc8fac1c445fe07cae159c3697ad2734432657) - **feat:** add boolean dtype support to `array/full-like` [(#2462)](https://github.com/stdlib-js/stdlib/pull/2462) _(by Jaysukh Makvana, Athan Reines)_
22882290
- [`3fdfa90`](https://github.com/stdlib-js/stdlib/commit/3fdfa902945e503766b1ae4592a2d094efb0ff7f) - **feat:** add boolean dtype support to `array/full` [(#2461)](https://github.com/stdlib-js/stdlib/pull/2461) _(by Jaysukh Makvana, Athan Reines)_
22892291
- [`b586995`](https://github.com/stdlib-js/stdlib/commit/b586995441d335964383ac2d3195ab9a55e091f4) - **feat:** add boolean dtype support to `array/base/mskreject` [(#2452)](https://github.com/stdlib-js/stdlib/pull/2452) _(by Jaysukh Makvana, Athan Reines)_

empty/README.md

+4-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2023 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.
@@ -49,22 +49,7 @@ var arr = empty( 2 );
4949
// returns <Float64Array>
5050
```
5151

52-
The function recognizes the following data types:
53-
54-
- `float64`: double-precision floating-point numbers (IEEE 754)
55-
- `float32`: single-precision floating-point numbers (IEEE 754)
56-
- `complex128`: double-precision complex floating-point numbers
57-
- `complex64`: single-precision complex floating-point numbers
58-
- `int32`: 32-bit two's complement signed integers
59-
- `uint32`: 32-bit unsigned integers
60-
- `int16`: 16-bit two's complement signed integers
61-
- `uint16`: 16-bit unsigned integers
62-
- `int8`: 8-bit two's complement signed integers
63-
- `uint8`: 8-bit unsigned integers
64-
- `uint8c`: 8-bit unsigned integers clamped to `0-255`
65-
- `generic`: generic JavaScript values
66-
67-
By default, the output array data type is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative data type, provide a `dtype` argument.
52+
By default, the output array [data type][@stdlib/array/dtypes] is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative [data type][@stdlib/array/dtypes], provide a `dtype` argument.
6853

6954
```javascript
7055
var arr = empty( 2, 'int32' );
@@ -149,6 +134,8 @@ for ( i = 0; i < dt.length; i++ ) {
149134

150135
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
151136

137+
[@stdlib/array/dtypes]: https://github.com/stdlib-js/array/tree/main/dtypes
138+
152139
<!-- <related-links> -->
153140

154141
[@stdlib/array/empty-like]: https://github.com/stdlib-js/array/tree/main/empty-like

empty/benchmark/benchmark.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 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.
@@ -83,6 +83,24 @@ bench( pkg+':dtype=float32', function benchmark( b ) {
8383
b.end();
8484
});
8585

86+
bench( pkg+':dtype=bool', function benchmark( b ) {
87+
var arr;
88+
var i;
89+
b.tic();
90+
for ( i = 0; i < b.iterations; i++ ) {
91+
arr = empty( 0, 'bool' );
92+
if ( arr.length !== 0 ) {
93+
b.fail( 'should have length 0' );
94+
}
95+
}
96+
b.toc();
97+
if ( !isTypedArrayLike( arr ) ) {
98+
b.fail( 'should return a typed array' );
99+
}
100+
b.pass( 'benchmark finished' );
101+
b.end();
102+
});
103+
86104
bench( pkg+':dtype=complex128', function benchmark( b ) {
87105
var arr;
88106
var i;
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pow = require( '@stdlib/math/base/special/pow' );
25+
var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' );
26+
var pkg = require( './../package.json' ).name;
27+
var empty = require( './../lib' );
28+
29+
30+
// FUNCTIONS //
31+
32+
/**
33+
* Creates a benchmark function.
34+
*
35+
* @private
36+
* @param {PositiveInteger} len - array length
37+
* @returns {Function} benchmark function
38+
*/
39+
function createBenchmark( len ) {
40+
return benchmark;
41+
42+
/**
43+
* Benchmark function.
44+
*
45+
* @private
46+
* @param {Benchmark} b - benchmark instance
47+
*/
48+
function benchmark( b ) {
49+
var arr;
50+
var i;
51+
52+
b.tic();
53+
for ( i = 0; i < b.iterations; i++ ) {
54+
arr = empty( len, 'bool' );
55+
if ( arr.length !== len ) {
56+
b.fail( 'unexpected length' );
57+
}
58+
}
59+
b.toc();
60+
if ( !isTypedArrayLike( arr ) ) {
61+
b.fail( 'should return a typed array' );
62+
}
63+
b.pass( 'benchmark finished' );
64+
b.end();
65+
}
66+
}
67+
68+
69+
// MAIN //
70+
71+
/**
72+
* Main execution sequence.
73+
*
74+
* @private
75+
*/
76+
function main() {
77+
var len;
78+
var min;
79+
var max;
80+
var f;
81+
var i;
82+
83+
min = 1; // 10^min
84+
max = 6; // 10^max
85+
86+
for ( i = min; i <= max; i++ ) {
87+
len = pow( 10, i );
88+
f = createBenchmark( len );
89+
bench( pkg+':dtype=bool,len='+len, f );
90+
}
91+
}
92+
93+
main();

empty/docs/repl.txt

-17
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,6 @@
1010
is *not* initialized. Memory contents are unknown and may contain
1111
*sensitive* data.
1212

13-
The function supports the following data types:
14-
15-
- float64: double-precision floating-point numbers (IEEE 754)
16-
- float32: single-precision floating-point numbers (IEEE 754)
17-
- complex128: double-precision complex floating-point numbers
18-
- complex64: single-precision complex floating-point numbers
19-
- int32: 32-bit two's complement signed integers
20-
- uint32: 32-bit unsigned integers
21-
- int16: 16-bit two's complement signed integers
22-
- uint16: 16-bit unsigned integers
23-
- int8: 8-bit two's complement signed integers
24-
- uint8: 8-bit unsigned integers
25-
- uint8c: 8-bit unsigned integers clamped to 0-255
26-
- generic: generic JavaScript values
27-
28-
The default array data type is `float64`.
29-
3013
Parameters
3114
----------
3215
length: integer

empty/docs/types/index.d.ts

-15
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,6 @@ import { DataTypeMap } from '@stdlib/types/array';
2525
/**
2626
* Creates an uninitialized array having a specified length.
2727
*
28-
* The function recognizes the following data types:
29-
*
30-
* - `float64`: double-precision floating-point numbers (IEEE 754)
31-
* - `float32`: single-precision floating-point numbers (IEEE 754)
32-
* - `complex128`: double-precision complex floating-point numbers
33-
* - `complex64`: single-precision complex floating-point numbers
34-
* - `int32`: 32-bit two's complement signed integers
35-
* - `uint32`: 32-bit unsigned integers
36-
* - `int16`: 16-bit two's complement signed integers
37-
* - `uint16`: 16-bit unsigned integers
38-
* - `int8`: 8-bit two's complement signed integers
39-
* - `uint8`: 8-bit unsigned integers
40-
* - `uint8c`: 8-bit unsigned integers clamped to `0-255`
41-
* - `generic`: generic JavaScript values
42-
*
4328
* ## Notes
4429
*
4530
* - In browser environments, the function always returns zero-filled arrays.

empty/docs/types/test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 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.
@@ -28,6 +28,7 @@ import empty = require( './index' );
2828
empty( 10, 'float32' ); // $ExpectType Float32Array
2929
empty( 10, 'complex128' ); // $ExpectType Complex128Array
3030
empty( 10, 'complex64' ); // $ExpectType Complex64Array
31+
empty( 10, 'bool' ); // $ExpectType BooleanArray
3132
empty( 10, 'int32' ); // $ExpectType Int32Array
3233
empty( 10, 'int16' ); // $ExpectType Int16Array
3334
empty( 10, 'int8' ); // $ExpectType Int8Array

empty/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"short",
101101
"long",
102102
"generic",
103+
"bool",
103104
"empty"
104105
]
105106
}

empty/test/test.main.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 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( './../../uint8' );
3232
var Uint8ClampedArray = require( './../../uint8c' );
3333
var Complex64Array = require( './../../complex64' );
3434
var Complex128Array = require( './../../complex128' );
35+
var BooleanArray = require( './../../bool' );
3536
var instanceOf = require( '@stdlib/assert/instance-of' );
3637
var empty = require( './../lib/main.js' );
3738

@@ -169,6 +170,16 @@ tape( 'the function returns an empty array (dtype=float32)', function test( t )
169170
t.end();
170171
});
171172

173+
tape( 'the function returns an empty array (dtype=bool)', function test( t ) {
174+
var arr;
175+
176+
arr = empty( 5, 'bool' );
177+
t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' );
178+
t.strictEqual( arr.length, 5, 'returns expected value' );
179+
180+
t.end();
181+
});
182+
172183
tape( 'the function returns an empty array (dtype=complex128)', function test( t ) {
173184
var arr;
174185

empty/test/test.polyfill.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 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,8 +32,10 @@ var Uint8Array = require( './../../uint8' );
3232
var Uint8ClampedArray = require( './../../uint8c' );
3333
var Complex64Array = require( './../../complex64' );
3434
var Complex128Array = require( './../../complex128' );
35+
var BooleanArray = require( './../../bool' );
3536
var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' );
3637
var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' );
38+
var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' );
3739
var instanceOf = require( '@stdlib/assert/instance-of' );
3840
var empty = require( './../lib/polyfill.js' );
3941

@@ -183,6 +185,20 @@ tape( 'the function returns a zero-filled array (dtype=float32)', function test(
183185
t.end();
184186
});
185187

188+
tape( 'the function returns a zero-filled array (dtype=bool)', function test( t ) {
189+
var expected;
190+
var arr;
191+
192+
expected = new Uint8Array( [ 0, 0, 0, 0 ] );
193+
194+
arr = empty( 4, 'bool' );
195+
t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' );
196+
t.strictEqual( arr.length, expected.length, 'returns expected value' );
197+
t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' );
198+
199+
t.end();
200+
});
201+
186202
tape( 'the function returns a zero-filled array (dtype=complex128)', function test( t ) {
187203
var expected;
188204
var arr;

0 commit comments

Comments
 (0)