Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jun 15, 2024
1 parent 616e0e8 commit 8eccb32
Show file tree
Hide file tree
Showing 16 changed files with 1,639 additions and 1 deletion.
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

## Unreleased (2024-06-14)
## Unreleased (2024-06-15)

<section class="packages">

Expand Down Expand Up @@ -667,6 +667,28 @@ This release closes the following issue:

<!-- /.package -->

<section class="package" id="array-base-cuany-unreleased">

#### [@stdlib/array/base/cuany](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/cuany)

<details>

<section class="features">

##### Features

- [`d9ef2aa`](https://github.com/stdlib-js/stdlib/commit/d9ef2aa6d8d5c22025ad552a21780b07462f3079) - add `array/base/cuany` [(#2375)](https://github.com/stdlib-js/stdlib/pull/2375)

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="array-base-fancy-slice-assign-unreleased">

#### [@stdlib/array/base/fancy-slice-assign](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/fancy-slice-assign)
Expand Down Expand Up @@ -1752,6 +1774,7 @@ A total of 13 people contributed to this release. Thank you to the following con

<details>

- [`d9ef2aa`](https://github.com/stdlib-js/stdlib/commit/d9ef2aa6d8d5c22025ad552a21780b07462f3079) - **feat:** add `array/base/cuany` [(#2375)](https://github.com/stdlib-js/stdlib/pull/2375) _(by Aditya Sapra, Athan Reines)_
- [`cba0d92`](https://github.com/stdlib-js/stdlib/commit/cba0d9249a25664a0b52f3ea2fe65eeddedd1e59) - **feat:** add `find` and `findLast` methods to `array/bool` [(#2376)](https://github.com/stdlib-js/stdlib/pull/2376) _(by Jaysukh Makvana)_
- [`c417923`](https://github.com/stdlib-js/stdlib/commit/c4179233cb2de5ffaa8c59b3910e14de12414483) - **feat:** add boolean dtype support in `array/dtypes` [(#2307)](https://github.com/stdlib-js/stdlib/pull/2307) _(by Jaysukh Makvana, Athan Reines)_
- [`2a174cd`](https://github.com/stdlib-js/stdlib/commit/2a174cd91a26e08e7032934762ef2c0ed0320bda) - **feat:** add boolean dtype support in `array/promotion-rules` [(#2369)](https://github.com/stdlib-js/stdlib/pull/2369) _(by Jaysukh Makvana, Athan Reines)_
Expand Down
114 changes: 114 additions & 0 deletions base/cuany/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<!--
@license Apache-2.0
Copyright (c) 2024 The Stdlib Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# cuany

> Cumulatively test whether at least one element in a provided array is truthy.
<section class="usage">

## Usage

```javascript
var cuany = require( '@stdlib/array/base/cuany' );
```

#### cuany( x )

Cumulatively tests whether at least one element in a provided array is truthy.

```javascript
var x = [ false, false, true, false, false ];

var y = cuany( x );
// returns [ false, false, true, true, true ];
```

#### cuany.assign( x, out, stride, offset )

Cumulatively tests whether at least one element in a provided array is truthy and assigns results to a provided output array.

```javascript
var x = [ false, false, true, false, false ];
var y = [ false, null, false, null, false, null, false, null, false, null ];

var out = cuany.assign( x, y, 2, 0 );
// returns [ false, null, false, null, true, null, true, null, true, null ]

var bool = ( out === y );
// returns true
```

The function supports the following parameters:

- **x**: input array.
- **out**: output array.
- **stride**: output array stride.
- **offset**: output array offset.

</section>

<!-- /.usage -->

<section class="notes">

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var bernoulli = require( '@stdlib/random/array/bernoulli' );
var cuany = require( '@stdlib/array/base/cuany' );

// Create an array of random values:
var x = bernoulli( 10, 0.1 );
console.log( x );

// Cumulatively determine whether values are truthy:
var out = cuany( x );
console.log( out );
```

</section>

<!-- /.examples -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">


</section>

<!-- /.links -->
98 changes: 98 additions & 0 deletions base/cuany/benchmark/benchmark.assign.length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var pow = require( '@stdlib/math/base/special/pow' );
var isArray = require( '@stdlib/assert/is-array' );
var filled = require('./../../../base/filled');
var pkg = require( './../package.json' ).name;
var cuany = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = filled( 1.5, len );
return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var y;
var v;
var i;

y = filled( false, len );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = cuany.assign( x, y, 1, 0 );
if ( typeof v !== 'object' ) {
b.fail( 'should return an array' );
}
}
b.toc();
if ( !isArray( v ) ) {
b.fail( 'should return an array' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+':assign:len='+len, f );
}
}

main();
51 changes: 51 additions & 0 deletions base/cuany/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var isArray = require( '@stdlib/assert/is-array' );
var pkg = require( './../package.json' ).name;
var cuany = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var x;
var i;
var v;

x = [ false, false, true, false, false ];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = cuany( x );
if ( typeof v !== 'object' ) {
b.fail( 'should return an array' );
}
}
b.toc();
if ( !isArray( v ) ) {
b.fail( 'should return an array' );
}
b.pass( 'benchmark finished' );
b.end();
});
Loading

0 comments on commit 8eccb32

Please sign in to comment.