Skip to content

Commit ea4288a

Browse files
committed
Auto-generated commit
1 parent 94740f9 commit ea4288a

17 files changed

Lines changed: 1906 additions & 92 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Features
1212

13+
- [`598f6bd`](https://github.com/stdlib-js/stdlib/commit/598f6bda7563b2cb2a656dbd27ae1437c13a6091) - add `falsesLike` to namespace
14+
- [`51957bb`](https://github.com/stdlib-js/stdlib/commit/51957bb310d8dfb72455771eb669683f499ba9a0) - add `ndarray/falses-like`
1315
- [`ef0c0ee`](https://github.com/stdlib-js/stdlib/commit/ef0c0ee0ca07b8e80443503eec824cb98a0f32fc) - add `trues` to namespace
1416
- [`afa41ed`](https://github.com/stdlib-js/stdlib/commit/afa41ed81e1f3a3d96baa463ad0df681b96490c3) - add `ndarray/trues`
1517
- [`3a2c420`](https://github.com/stdlib-js/stdlib/commit/3a2c4202494b17834a1d35227a9d79aa7339cac1) - add `falses` to namespace
@@ -952,6 +954,11 @@ A total of 49 issues were closed in this release:
952954

953955
<details>
954956

957+
- [`598f6bd`](https://github.com/stdlib-js/stdlib/commit/598f6bda7563b2cb2a656dbd27ae1437c13a6091) - **feat:** add `falsesLike` to namespace _(by Athan Reines)_
958+
- [`51957bb`](https://github.com/stdlib-js/stdlib/commit/51957bb310d8dfb72455771eb669683f499ba9a0) - **feat:** add `ndarray/falses-like` _(by Athan Reines)_
959+
- [`612bd5d`](https://github.com/stdlib-js/stdlib/commit/612bd5d66a0c0c394b501f9aa660355079816960) - **test:** use ndarray instance rather than ndarray-like objects _(by Athan Reines)_
960+
- [`08ad397`](https://github.com/stdlib-js/stdlib/commit/08ad39702cee5aa0f6be202da23876076b66d5b3) - **test:** use ndarray instance rather than ndarray-like objects _(by Athan Reines)_
961+
- [`84ca269`](https://github.com/stdlib-js/stdlib/commit/84ca26945e2e2c705a1a0bfcb00bf0fd235f990b) - **test:** use ndarray instance rather than ndarray-like objects _(by Athan Reines)_
955962
- [`8a676c9`](https://github.com/stdlib-js/stdlib/commit/8a676c90f885ee4c0ffd9b324f4e4707ea025843) - **docs:** update namespace table of contents [(#12189)](https://github.com/stdlib-js/stdlib/pull/12189) _(by stdlib-bot)_
956963
- [`1816701`](https://github.com/stdlib-js/stdlib/commit/1816701617f0b3442bc898097ac129382cc699a3) - **docs:** update descriptions in `ndarray/base/*-like` packages [(#12145)](https://github.com/stdlib-js/stdlib/pull/12145) _(by Philipp Burckhardt)_
957964
- [`9e72d5a`](https://github.com/stdlib-js/stdlib/commit/9e72d5af562d400e9bd580faa9f80ed2ebc6aa4c) - **docs:** update related packages sections [(#12185)](https://github.com/stdlib-js/stdlib/pull/12185) _(by stdlib-bot)_

falses-like/README.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
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+
# falsesLike
22+
23+
> Create a NaN-filled [ndarray][@stdlib/ndarray/ctor] having the same shape and [data type][@stdlib/ndarray/dtypes] as a provided ndarray.
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 falsesLike = require( '@stdlib/ndarray/falses-like' );
41+
```
42+
43+
#### falsesLike( x\[, options] )
44+
45+
Creates a NaN-filled [ndarray][@stdlib/ndarray/ctor] having the same shape and [data type][@stdlib/ndarray/dtypes] as a provided ndarray.
46+
47+
```javascript
48+
var getShape = require( '@stdlib/ndarray/shape' );
49+
var getDType = require( '@stdlib/ndarray/dtype' );
50+
var empty = require( '@stdlib/ndarray/empty' );
51+
52+
var x = empty( [ 2, 2 ], {
53+
'dtype': 'bool'
54+
});
55+
// returns <ndarray>
56+
57+
var y = falsesLike( x );
58+
// returns <ndarray>[ [ false, false ], [ false, false ] ]
59+
60+
var sh = getShape( y );
61+
// returns [ 2, 2 ]
62+
63+
var dt = String( getDType( y ) );
64+
// returns 'bool'
65+
```
66+
67+
The function supports the following options:
68+
69+
- **dtype**: output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes]. Must be a boolean or "generic" [data type][@stdlib/ndarray/dtypes]. Overrides the input ndarray's inferred [data type][@stdlib/ndarray/dtypes].
70+
- **shape**: output [ndarray][@stdlib/ndarray/ctor] shape. Overrides the input ndarray's inferred shape.
71+
- **order**: specifies whether the output [ndarray][@stdlib/ndarray/ctor] should be `'row-major'` (C-style) or `'column-major'` (Fortran-style). Overrides the input ndarray's inferred order.
72+
- **mode**: specifies how to handle indices which exceed array dimensions (see [ndarray][@stdlib/ndarray/ctor]). Default: `'throw'`.
73+
- **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 ]`.
74+
- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`.
75+
76+
To override either the `dtype`, `shape`, or `order`, specify the corresponding option. For example, to override the inferred [data type][@stdlib/ndarray/dtypes],
77+
78+
```javascript
79+
var getShape = require( '@stdlib/ndarray/shape' );
80+
var getDType = require( '@stdlib/ndarray/dtype' );
81+
var empty = require( '@stdlib/ndarray/empty' );
82+
83+
var x = empty( [ 2, 2 ], {
84+
'dtype': 'bool'
85+
});
86+
// returns <ndarray>
87+
88+
var dt = String( getDType( x ) );
89+
// returns 'bool'
90+
91+
var y = falsesLike( x, {
92+
'dtype': 'generic'
93+
});
94+
// returns <ndarray>[ [ false, false ], [ false, false ] ]
95+
96+
var sh = getShape( y );
97+
// returns [ 2, 2 ]
98+
99+
dt = String( getDType( y ) );
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 empty = require( '@stdlib/ndarray/empty' );
125+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
126+
var falsesLike = require( '@stdlib/ndarray/falses-like' );
127+
128+
// Specify a list of data types:
129+
var dt = [
130+
'bool',
131+
'generic'
132+
];
133+
134+
// Generate filled ndarrays...
135+
var x;
136+
var y;
137+
var i;
138+
for ( i = 0; i < dt.length; i++ ) {
139+
x = empty( [ 2, 2 ], {
140+
'dtype': dt[ i ]
141+
});
142+
y = falsesLike( x );
143+
console.log( ndarray2array( y ) );
144+
}
145+
```
146+
147+
</section>
148+
149+
<!-- /.examples -->
150+
151+
<!-- 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. -->
152+
153+
<section class="references">
154+
155+
</section>
156+
157+
<!-- /.references -->
158+
159+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
160+
161+
<section class="related">
162+
163+
</section>
164+
165+
<!-- /.related -->
166+
167+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
168+
169+
<section class="links">
170+
171+
[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray/tree/main/ctor
172+
173+
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray/tree/main/dtypes
174+
175+
</section>
176+
177+
<!-- /.links -->

falses-like/benchmark/benchmark.js

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

0 commit comments

Comments
 (0)