Skip to content

Commit 3207cce

Browse files
committed
Auto-generated commit
1 parent c7d33ef commit 3207cce

14 files changed

Lines changed: 1775 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
<section class="release" id="unreleased">
66

7-
## Unreleased (2026-05-17)
7+
## Unreleased (2026-05-18)
88

99
<section class="features">
1010

1111
### Features
1212

13+
- [`3a2c420`](https://github.com/stdlib-js/stdlib/commit/3a2c4202494b17834a1d35227a9d79aa7339cac1) - add `falses` to namespace
14+
- [`fad2314`](https://github.com/stdlib-js/stdlib/commit/fad2314e74226b9cfc8c983a83cfd32a68360a56) - add `ndarray/falses`
1315
- [`043d7df`](https://github.com/stdlib-js/stdlib/commit/043d7df01c4423ca2ef6b80f1003df5049f98296) - add `truesLike` to namespace
1416
- [`2e5a8c9`](https://github.com/stdlib-js/stdlib/commit/2e5a8c97037ab5c11bcddca57bb986994f9d5561) - add `ndarray/base/trues-like`
1517
- [`ff61c1a`](https://github.com/stdlib-js/stdlib/commit/ff61c1a0ff66321e8755b17eb152c86dc79ba18d) - add `falsesLike` to namespace
@@ -948,6 +950,8 @@ A total of 49 issues were closed in this release:
948950

949951
<details>
950952

953+
- [`3a2c420`](https://github.com/stdlib-js/stdlib/commit/3a2c4202494b17834a1d35227a9d79aa7339cac1) - **feat:** add `falses` to namespace _(by Athan Reines)_
954+
- [`fad2314`](https://github.com/stdlib-js/stdlib/commit/fad2314e74226b9cfc8c983a83cfd32a68360a56) - **feat:** add `ndarray/falses` _(by Athan Reines)_
951955
- [`b2eb5da`](https://github.com/stdlib-js/stdlib/commit/b2eb5da5b94858e0d40f62ebe33ef5f52d398acc) - **docs:** update related packages sections [(#12164)](https://github.com/stdlib-js/stdlib/pull/12164) _(by stdlib-bot)_
952956
- [`66ec9de`](https://github.com/stdlib-js/stdlib/commit/66ec9de8d5be3960d329762c2c132adcbd35337d) - **docs:** update namespace table of contents [(#12151)](https://github.com/stdlib-js/stdlib/pull/12151) _(by stdlib-bot)_
953957
- [`f0ed784`](https://github.com/stdlib-js/stdlib/commit/f0ed784caa00e817f71e1191b5db3853b57fa570) - **bench:** refactor to use string interpolation _(by Athan Reines)_

‎falses/README.md‎

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2026 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# falses
22+
23+
> Create an [ndarray][@stdlib/ndarray/ctor] filled with `false` values and having a specified shape and [data type][@stdlib/ndarray/dtypes].
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<!-- Package usage documentation. -->
34+
35+
<section class="usage">
36+
37+
## Usage
38+
39+
```javascript
40+
var falses = require( '@stdlib/ndarray/falses' );
41+
```
42+
43+
#### falses( shape\[, options] )
44+
45+
Creates an [ndarray][@stdlib/ndarray/ctor] filled with `false` values and having a specified shape and [data type][@stdlib/ndarray/dtypes].
46+
47+
```javascript
48+
var getShape = require( '@stdlib/ndarray/shape' );
49+
var getDType = require( '@stdlib/ndarray/dtype' );
50+
51+
var arr = falses( [ 2, 2 ] );
52+
// returns <ndarray>[ [ false, false ], [ false, false ] ]
53+
54+
var sh = getShape( arr );
55+
// returns [ 2, 2 ]
56+
57+
var dt = String( getDType( arr ) );
58+
// returns 'bool'
59+
```
60+
61+
The specified output [ndarray][@stdlib/ndarray/ctor] shape may be either an array-like object or an integer value.
62+
63+
```javascript
64+
var getShape = require( '@stdlib/ndarray/shape' );
65+
var getDType = require( '@stdlib/ndarray/dtype' );
66+
67+
var arr = falses( 2 );
68+
// returns <ndarray>[ false, false ]
69+
70+
var sh = getShape( arr );
71+
// returns [ 2 ]
72+
73+
var dt = String( getDType( arr ) );
74+
// returns 'bool'
75+
```
76+
77+
The function accepts the following options:
78+
79+
- **dtype**: underlying [data type][@stdlib/ndarray/dtypes]. Must be a boolean or "generic" [data type][@stdlib/ndarray/dtypes]. Default: `'bool'`.
80+
- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`.
81+
- **mode**: specifies how to handle indices which exceed array dimensions (see [ndarray][@stdlib/ndarray/ctor]). Default: `'throw'`.
82+
- **submode**: a mode array which specifies for each dimension how to handle subscripts which exceed array dimensions (see [ndarray][@stdlib/ndarray/ctor]). If provided fewer modes than dimensions, the constructor recycles modes using modulo arithmetic. Default: `[ options.mode ]`.
83+
- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`.
84+
85+
By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having a [`bool`][@stdlib/ndarray/dtypes] data type. To specify an alternative [data type][@stdlib/ndarray/dtypes], provide a `dtype` option.
86+
87+
```javascript
88+
var getShape = require( '@stdlib/ndarray/shape' );
89+
var getDType = require( '@stdlib/ndarray/dtype' );
90+
91+
var arr = falses( [ 2, 2 ], {
92+
'dtype': 'generic'
93+
});
94+
// returns <ndarray>[ [ false, false ], [ false, false ] ]
95+
96+
var sh = getShape( arr );
97+
// returns [ 2, 2 ]
98+
99+
var dt = String( getDType( arr ) );
100+
// returns 'generic'
101+
```
102+
103+
</section>
104+
105+
<!-- /.usage -->
106+
107+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
108+
109+
<section class="notes">
110+
111+
</section>
112+
113+
<!-- /.notes -->
114+
115+
<!-- Package usage examples. -->
116+
117+
<section class="examples">
118+
119+
## Examples
120+
121+
<!-- eslint no-undef: "error" -->
122+
123+
```javascript
124+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
125+
var falses = require( '@stdlib/ndarray/falses' );
126+
127+
// Specify a list of data types:
128+
var dt = [
129+
'bool',
130+
'generic'
131+
];
132+
133+
// Generate filled ndarrays...
134+
var arr;
135+
var i;
136+
for ( i = 0; i < dt.length; i++ ) {
137+
arr = falses( [ 2, 2 ], {
138+
'dtype': dt[ i ]
139+
});
140+
console.log( ndarray2array( arr ) );
141+
}
142+
```
143+
144+
</section>
145+
146+
<!-- /.examples -->
147+
148+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
149+
150+
<section class="references">
151+
152+
</section>
153+
154+
<!-- /.references -->
155+
156+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
157+
158+
<section class="related">
159+
160+
</section>
161+
162+
<!-- /.related -->
163+
164+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
165+
166+
<section class="links">
167+
168+
[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray/tree/main/ctor
169+
170+
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray/tree/main/dtypes
171+
172+
</section>
173+
174+
<!-- /.links -->

‎falses/benchmark/benchmark.js‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
25+
var format = require( '@stdlib/string/format' );
26+
var pkg = require( './../package.json' ).name;
27+
var falses = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg, function benchmark( b ) {
33+
var arr;
34+
var i;
35+
b.tic();
36+
for ( i = 0; i < b.iterations; i++ ) {
37+
arr = falses( [ 0 ] );
38+
if ( arr.length !== 0 ) {
39+
b.fail( 'should have length 0' );
40+
}
41+
}
42+
b.toc();
43+
if ( !isndarrayLike( arr ) ) {
44+
b.fail( 'should return an ndarray' );
45+
}
46+
b.pass( 'benchmark finished' );
47+
b.end();
48+
});
49+
50+
bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) {
51+
var arr;
52+
var i;
53+
b.tic();
54+
for ( i = 0; i < b.iterations; i++ ) {
55+
arr = falses( [ 0 ], {
56+
'dtype': 'bool'
57+
});
58+
if ( arr.length !== 0 ) {
59+
b.fail( 'should have length 0' );
60+
}
61+
}
62+
b.toc();
63+
if ( !isndarrayLike( arr ) ) {
64+
b.fail( 'should return an ndarray' );
65+
}
66+
b.pass( 'benchmark finished' );
67+
b.end();
68+
});
69+
70+
bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) {
71+
var arr;
72+
var i;
73+
b.tic();
74+
for ( i = 0; i < b.iterations; i++ ) {
75+
arr = falses( [ 0 ], {
76+
'dtype': 'generic'
77+
});
78+
if ( arr.length !== 0 ) {
79+
b.fail( 'should have length 0' );
80+
}
81+
}
82+
b.toc();
83+
if ( !isndarrayLike( arr ) ) {
84+
b.fail( 'should return an ndarray' );
85+
}
86+
b.pass( 'benchmark finished' );
87+
b.end();
88+
});
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
26+
var format = require( '@stdlib/string/format' );
27+
var pkg = require( './../package.json' ).name;
28+
var falses = require( './../lib' );
29+
30+
31+
// FUNCTIONS //
32+
33+
/**
34+
* Creates a benchmark function.
35+
*
36+
* @private
37+
* @param {PositiveInteger} len - array length
38+
* @returns {Function} benchmark function
39+
*/
40+
function createBenchmark( len ) {
41+
return benchmark;
42+
43+
/**
44+
* Benchmark function.
45+
*
46+
* @private
47+
* @param {Benchmark} b - benchmark instance
48+
*/
49+
function benchmark( b ) {
50+
var opts;
51+
var arr;
52+
var i;
53+
54+
opts = {
55+
'dtype': 'bool'
56+
};
57+
58+
b.tic();
59+
for ( i = 0; i < b.iterations; i++ ) {
60+
arr = falses( [ len ], opts );
61+
if ( arr.length !== len ) {
62+
b.fail( 'unexpected length' );
63+
}
64+
}
65+
b.toc();
66+
if ( !isndarrayLike( arr ) ) {
67+
b.fail( 'should return an ndarray' );
68+
}
69+
b.pass( 'benchmark finished' );
70+
b.end();
71+
}
72+
}
73+
74+
75+
// MAIN //
76+
77+
/**
78+
* Main execution sequence.
79+
*
80+
* @private
81+
*/
82+
function main() {
83+
var len;
84+
var min;
85+
var max;
86+
var f;
87+
var i;
88+
89+
min = 1; // 10^min
90+
max = 6; // 10^max
91+
92+
for ( i = min; i <= max; i++ ) {
93+
len = pow( 10, i );
94+
f = createBenchmark( len );
95+
bench( format( '%s:dtype=bool,size=%d', pkg, len ), f );
96+
}
97+
}
98+
99+
main();

0 commit comments

Comments
 (0)