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 Aug 17, 2024
1 parent 1226c95 commit f6acfae
Show file tree
Hide file tree
Showing 28 changed files with 3,780 additions and 412 deletions.
42 changes: 41 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-08-16)
## Unreleased (2024-08-17)

<section class="packages">

Expand Down Expand Up @@ -77,6 +77,7 @@

##### Features

- [`297e4d5`](https://github.com/stdlib-js/stdlib/commit/297e4d5c9c1b015ccf8c7bb77c672e9ac1328898) - add `without` to namespace
- [`29641e1`](https://github.com/stdlib-js/stdlib/commit/29641e155d07e3aa7e71340d47ada3e43d1edaa5) - add `cunone` to namespace
- [`a596d0c`](https://github.com/stdlib-js/stdlib/commit/a596d0c68b97049ec249e9c51caf7e2d34190f4a) - add `removeAt` to namespace
- [`00fd68d`](https://github.com/stdlib-js/stdlib/commit/00fd68ddf80a71b08e5353c63c297fca4daaf873) - update namespace TypeScript declarations [(#2415)](https://github.com/stdlib-js/stdlib/pull/2415)
Expand Down Expand Up @@ -1308,12 +1309,45 @@ This release closes the following issue:

##### Features

- [`15c9b0e`](https://github.com/stdlib-js/stdlib/commit/15c9b0e711e44c7e06ba768ab577d8cffdc5647d) - add support for assigning to an output array
- [`4253607`](https://github.com/stdlib-js/stdlib/commit/425360790cca3ef7b1747b3c1828ab5825306441) - add `array/base/with` [(#1374)](https://github.com/stdlib-js/stdlib/pull/1374)

</section>

<!-- /.features -->

<section class="bug-fixes">

##### Bug Fixes

- [`45bfdb6`](https://github.com/stdlib-js/stdlib/commit/45bfdb698f5b5b31e1782efe846b76ee64ab032a) - update error messages to accommodate signed integers

</section>

<!-- /.bug-fixes -->

</details>

</section>

<!-- /.package -->

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

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

<details>

<section class="features">

##### Features

- [`f6df528`](https://github.com/stdlib-js/stdlib/commit/f6df52818f504fd55987a80f586ad55b40405d58) - add `array/base/without`

</section>

<!-- /.features -->

</details>

</section>
Expand Down Expand Up @@ -2435,6 +2469,12 @@ A total of 10 people contributed to this release. Thank you to the following con

<details>

- [`297e4d5`](https://github.com/stdlib-js/stdlib/commit/297e4d5c9c1b015ccf8c7bb77c672e9ac1328898) - **feat:** add `without` to namespace _(by Athan Reines)_
- [`f6df528`](https://github.com/stdlib-js/stdlib/commit/f6df52818f504fd55987a80f586ad55b40405d58) - **feat:** add `array/base/without` _(by Athan Reines)_
- [`e22b37a`](https://github.com/stdlib-js/stdlib/commit/e22b37aaf13a81aa9c8536d54b8a43871e4bdd16) - **docs:** add example _(by Athan Reines)_
- [`1f1c2df`](https://github.com/stdlib-js/stdlib/commit/1f1c2dfc7314a343282c8d4904a8ad05c500f80d) - **docs:** fix example _(by Athan Reines)_
- [`15c9b0e`](https://github.com/stdlib-js/stdlib/commit/15c9b0e711e44c7e06ba768ab577d8cffdc5647d) - **feat:** add support for assigning to an output array _(by Athan Reines)_
- [`45bfdb6`](https://github.com/stdlib-js/stdlib/commit/45bfdb698f5b5b31e1782efe846b76ee64ab032a) - **fix:** update error messages to accommodate signed integers _(by Athan Reines)_
- [`29641e1`](https://github.com/stdlib-js/stdlib/commit/29641e155d07e3aa7e71340d47ada3e43d1edaa5) - **feat:** add `cunone` to namespace _(by Athan Reines)_
- [`a596d0c`](https://github.com/stdlib-js/stdlib/commit/a596d0c68b97049ec249e9c51caf7e2d34190f4a) - **feat:** add `removeAt` to namespace _(by Athan Reines)_
- [`400fcbb`](https://github.com/stdlib-js/stdlib/commit/400fcbb91753cc2a47d428a65a29ee455a208768) - **refactor:** avoid unnecessary copies, update examples, and refactor benchmarks _(by Athan Reines)_
Expand Down
9 changes: 9 additions & 0 deletions base/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,15 @@ setReadOnly( ns, 'where', require( './../../base/where' ) );
*/
setReadOnly( ns, 'arrayWith', require( './../../base/with' ) );

/**
* @name without
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/array/base/without}
*/
setReadOnly( ns, 'without', require( './../../base/without' ) );

/**
* @name zeroTo
* @memberof ns
Expand Down
27 changes: 25 additions & 2 deletions base/with/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,37 @@ var out = arrayWith( x, 0, 5 );

out = arrayWith( x, -1, 6 );
// returns [ 1, 2, 3, 6 ]
```

The function accepts the following arguments:

- **x**: an input array.
- **index**: element index.
- **value**: replacement value.

### arrayWith.assign( x, index, value, out, stride, offset )

Copies elements from one array to another array and sets the element at the specified index to a provided value.

```javascript
var x = [ 1, 2, 3, 4 ];

var out = [ 0, 0, 0, 0 ];
var arr = arrayWith.assign( x, 0, 5, out, 1, 0 );
// returns [ 5, 2, 3, 4 ]

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

The function accepts the following arguments:

- **x**: an input array.
- **index**: element index.
- **value**: replacement value.
- **out**: output array.
- **stride**: output array stride.
- **offset**: output array offset.

</section>

Expand All @@ -71,13 +94,13 @@ The function accepts the following arguments:

## Notes

- If provided an array-like object having a `with` method, the function defers execution to that method and assumes that the method has the following signature:
- If provided an array-like object having a `with` method, the `arrayWith` function defers execution to that method and assumes that the method has the following signature:

```text
x.with( index, value )
```
If provided an array-like object without a `with` method, the function shallow copies input array data to a new generic array, normalizes a provided index, and sets a specified element.
If provided an array-like object without a `with` method, the `arrayWith` function shallow copies input array data to a new generic array, normalizes a provided index, and sets a specified element.
- Negative indices are resolved relative to the last array element, with the last element corresponding to `-1`.
Expand Down
98 changes: 98 additions & 0 deletions base/with/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 ones = require( './../../../base/ones' );
var zeros = require( './../../../base/zeros' );
var pkg = require( './../package.json' ).name;
var arrayWith = require( './../lib' );


// FUNCTIONS //

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

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = arrayWith.assign( x, i%len, i, out, 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:dtype=generic,len='+len, f );
}
}

main();
File renamed without changes.
42 changes: 42 additions & 0 deletions base/with/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,48 @@
> x
[ 1, 2, 3, 4 ]


{{alias}}.assign( x, index, value, out, stride, offset )
Copies elements from one array to another array and sets the element at the
specified index to a provided value.

Negative indices are resolved relative to the last array element, with the
last element corresponding to `-1`.

Parameters
----------
x: ArrayLikeObject
Input array.

index: integer
Index of the element to be replaced.

value: any
Replacement value.

out: ArrayLikeObject
Output array.

stride: integer
Output array stride.

offset: integer
Output array offset.

Returns
-------
out: ArrayLikeObject
Output array.

Examples
--------
> var x = [ 1, 2, 3, 4 ];
> var out = [ 0, 0, 0, 0 ];
> var arr = {{alias}}.assign( x, 0, 5, out, 1, 0 )
[ 5, 2, 3, 4 ]
> var bool = ( arr === out )
true

See Also
--------

Loading

0 comments on commit f6acfae

Please sign in to comment.