Skip to content

Commit 17b1ae0

Browse files
committed
Auto-generated commit
1 parent 054af5e commit 17b1ae0

File tree

8 files changed

+41
-36
lines changed

8 files changed

+41
-36
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ A total of 40 issues were closed in this release:
702702

703703
<details>
704704

705+
- [`8ea33d5`](https://github.com/stdlib-js/stdlib/commit/8ea33d58d9a5beb31e6023ceaf331fc4175c74fa) - **docs:** rename parameter _(by Athan Reines)_
705706
- [`5149a6b`](https://github.com/stdlib-js/stdlib/commit/5149a6b650b60568bd0df248c2a97a3d8ca2ca87) - **chore:** minor clean-up _(by Philipp Burckhardt)_
706707
- [`1aff763`](https://github.com/stdlib-js/stdlib/commit/1aff763c61863b7d737a699db89729d2bba0e1bc) - **feat:** add `ndarray/spread-dimensions` [(#9424)](https://github.com/stdlib-js/stdlib/pull/9424) _(by Muhammad Haris, Athan Reines)_
707708
- [`9d53583`](https://github.com/stdlib-js/stdlib/commit/9d53583c9f82e1b2e5dc084849d98bd9c3214d45) - **test:** update descriptions _(by Athan Reines)_

base/expand-dimensions/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# expandDimensions
2222

23-
> Expand the shape of an array by inserting a new dimension of size one at a specified axis.
23+
> Expand the shape of an array by inserting a new dimension of size one at a specified dimension index.
2424
2525
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
2626

@@ -40,9 +40,9 @@ limitations under the License.
4040
var expandDimensions = require( '@stdlib/ndarray/base/expand-dimensions' );
4141
```
4242

43-
#### expandDimensions( x, axis, writable )
43+
#### expandDimensions( x, dim, writable )
4444

45-
Expands the shape of an array `x` by inserting a new dimension of size one at a specified `axis`.
45+
Expands the shape of an array `x` by inserting a new dimension of size one at a specified dimension index.
4646

4747
```javascript
4848
var getShape = require( '@stdlib/ndarray/shape' );
@@ -77,7 +77,7 @@ sh = getShape( y );
7777
The function accepts the following arguments:
7878

7979
- **x**: input ndarray.
80-
- **axis**: axis at which to insert a singleton dimension.
80+
- **dim**: dimension index at which to insert a singleton dimension.
8181
- **writable**: boolean indicating whether a returned ndarray should be writable.
8282

8383
</section>
@@ -90,7 +90,7 @@ The function accepts the following arguments:
9090

9191
## Notes
9292

93-
- A provided axis must reside on the interval `[-N-1, N]`, where `N` is the rank (i.e., number of dimensions) of the provided input array. If provided a negative `axis`, the axis position at which to insert a singleton dimension is computed as `N + axis + 1`. Hence, if provided `-1`, the resolved axis position is `N` (i.e., a singleton dimension is appended to the input array).
93+
- A provided dimension index must reside on the interval `[-N-1, N]`, where `N` is the rank (i.e., number of dimensions) of the provided input array. If provided a negative dimension index, the position at which to insert a singleton dimension is computed as `N + dim + 1`. Hence, if provided `-1`, the resolved position is `N` (i.e., a singleton dimension is appended to the input array).
9494
- The `writable` parameter **only** applies to ndarray constructors supporting **read-only** instances.
9595

9696
</section>

base/expand-dimensions/docs/repl.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11

2-
{{alias}}( x, axis, writable )
2+
{{alias}}( x, dim, writable )
33
Expands the shape of an array by inserting a new dimension of size one at a
4-
specified axis.
4+
specified dimension index.
55

6-
A provided axis must reside on the interval `[-N-1, N]`, where `N` is the
7-
rank (i.e., number of dimensions) of the provided input array.
6+
A provided dimension index must reside on the interval `[-N-1, N]`, where
7+
`N` is the rank (i.e., number of dimensions) of the provided input array.
88

9-
If provided a negative axis value, the axis position at which to insert a
10-
singleton dimension is computed as `N + axis + 1`. Hence, if provided `-1`,
11-
the resolved axis position is `N` (i.e., a singleton dimension is appended
12-
to the input array).
9+
If provided a negative dimension index, the position at which to insert a
10+
singleton dimension is computed as `N + dim + 1`. Hence, if provided `-1`,
11+
the resolved position is `N` (i.e., a singleton dimension is appended to the
12+
input array).
1313

1414
The `writable` parameter only applies to ndarray constructors supporting
1515
read-only instances.
@@ -19,8 +19,8 @@
1919
x: ndarray
2020
Input array.
2121

22-
axis: integer
23-
Axis at which to insert a singleton dimension.
22+
dim: integer
23+
Dimension index at which to insert a singleton dimension.
2424

2525
writable: boolean
2626
Boolean indicating whether the returned ndarray should be writable.

base/expand-dimensions/docs/types/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
import { typedndarray } from '@stdlib/types/ndarray';
2424

2525
/**
26-
* Expands the shape of an array by inserting a new dimension of size one at a specified axis.
26+
* Expands the shape of an array by inserting a new dimension of size one at a specified dimension index.
2727
*
2828
* ## Notes
2929
*
30-
* - A provided axis must reside on the interval `[-N-1, N]`, where `N` is the rank (i.e., number of dimensions) of the provided input array. If provided a negative `axis`, the axis position at which to insert a singleton dimension is computed as `N + axis + 1`. Hence, if provided `-1`, the resolved axis position is `N` (i.e., a singleton dimension is appended to the input array).
30+
* - A provided dimension index must reside on the interval `[-N-1, N]`, where `N` is the rank (i.e., number of dimensions) of the provided input array. If provided a negative dimension index, the position at which to insert a singleton dimension is computed as `N + dim + 1`. Hence, if provided `-1`, the resolved position is `N` (i.e., a singleton dimension is appended to the input array).
3131
*
3232
* @param x - input array
33-
* @param axis - axis at which to insert a singleton dimension
33+
* @param dim - dimension index at which to insert a singleton dimension
3434
* @param writable - boolean indicating whether the returned ndarray should be writable
3535
* @returns output array
3636
*
@@ -43,7 +43,7 @@ import { typedndarray } from '@stdlib/types/ndarray';
4343
* var y = expandDimensions( x, 1, false );
4444
* // returns <ndarray>[ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]
4545
*/
46-
declare function expandDimensions<T = unknown>( x: typedndarray<T>, axis: number, writable: boolean ): typedndarray<T>;
46+
declare function expandDimensions<T = unknown, U extends typedndarray<T> = typedndarray<T>>( x: U, dim: number, writable: boolean ): U;
4747

4848

4949
// EXPORTS //

base/expand-dimensions/docs/types/test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19+
/* eslint-disable space-in-parens */
20+
1921
import zeros = require( './../../../../zeros' );
2022
import expandDimensions = require( './index' );
2123

@@ -24,9 +26,11 @@ import expandDimensions = require( './index' );
2426

2527
// The function returns an ndarray...
2628
{
27-
const x = zeros( [ 2, 2 ] );
29+
const x = zeros( [ 2, 2 ], {
30+
'dtype': 'float64'
31+
});
2832

29-
expandDimensions( x, 1, false ); // $ExpectType typedndarray<number>
33+
expandDimensions( x, 1, false ); // $ExpectType float64ndarray
3034
}
3135

3236
// The compiler throws an error if the function is not provided a first argument which is an ndarray...

base/expand-dimensions/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Expand the shape of an array by inserting a new dimension of size one at a specified axis.
22+
* Expand the shape of an array by inserting a new dimension of size one at a specified dimension index.
2323
*
2424
* @module @stdlib/ndarray/base/expand-dimensions
2525
*

base/expand-dimensions/lib/main.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ var format = require( '@stdlib/string/format' );
3434
// MAIN //
3535

3636
/**
37-
* Expands the shape of an array by inserting a new dimension of size one at a specified axis.
37+
* Expands the shape of an array by inserting a new dimension of size one at a specified dimension index.
3838
*
3939
* ## Notes
4040
*
41-
* - A provided axis must reside on the interval `[-N-1, N]`, where `N` is the rank (i.e., number of dimensions) of the provided input array. If provided a negative `axis`, the axis position at which to insert a singleton dimension is computed as `N + axis + 1`. Hence, if provided `-1`, the resolved axis position is `N` (i.e., a singleton dimension is appended to the input array).
41+
* - A provided dimension index must reside on the interval `[-N-1, N]`, where `N` is the rank (i.e., number of dimensions) of the provided input array. If provided a negative dimension index, the position at which to insert a singleton dimension is computed as `N + dim + 1`. Hence, if provided `-1`, the resolved position is `N` (i.e., a singleton dimension is appended to the input array).
4242
*
4343
* @param {ndarray} x - input array
44-
* @param {integer} axis - axis at which to insert a singleton dimension
44+
* @param {integer} dim - dimension index at which to insert a singleton dimension
4545
* @param {boolean} writable - boolean indicating whether the returned ndarray should be writable
46-
* @throws {RangeError} must provide a valid axis
46+
* @throws {RangeError} must provide a valid dimension index
4747
* @returns {ndarray} output array
4848
*
4949
* @example
@@ -55,7 +55,7 @@ var format = require( '@stdlib/string/format' );
5555
* var y = expandDimensions( x, 1, false );
5656
* // returns <ndarray>[ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]
5757
*/
58-
function expandDimensions( x, axis, writable ) {
58+
function expandDimensions( x, dim, writable ) {
5959
var strides;
6060
var shape;
6161
var isrm;
@@ -76,9 +76,9 @@ function expandDimensions( x, axis, writable ) {
7676
strides = [];
7777
shape = [];
7878

79-
d = normalizeIndex( axis, N );
79+
d = normalizeIndex( dim, N );
8080
if ( d === -1 ) {
81-
throw new RangeError( format( 'invalid argument. Specified axis is out-of-bounds. Must be on the interval: [-%u, %u]. Value: `%d`.', N+1, N, axis ) );
81+
throw new RangeError( format( 'invalid argument. Specified dimension index is out-of-bounds. Must be on the interval: [-%u, %u]. Value: `%d`.', N+1, N, dim ) );
8282
}
8383
if ( d === 0 ) {
8484
// Prepend singleton dimension...

base/expand-dimensions/test/test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ tape( 'main export is a function', function test( t ) {
3939
t.end();
4040
});
4141

42-
tape( 'the function throws an error if provided an invalid `axis` argument', function test( t ) {
42+
tape( 'the function throws an error if provided an invalid second argument', function test( t ) {
4343
var values;
4444
var x;
4545
var i;
@@ -87,7 +87,7 @@ tape( 'the function prepends singleton dimensions', function test( t ) {
8787
t.end();
8888
});
8989

90-
tape( 'the function prepends singleton dimensions (negative axis)', function test( t ) {
90+
tape( 'the function prepends singleton dimensions (negative index)', function test( t ) {
9191
var x;
9292
var y;
9393

@@ -133,7 +133,7 @@ tape( 'the function appends singleton dimensions', function test( t ) {
133133
t.end();
134134
});
135135

136-
tape( 'the function appends singleton dimensions (negative axis)', function test( t ) {
136+
tape( 'the function appends singleton dimensions (negative index)', function test( t ) {
137137
var x;
138138
var y;
139139

@@ -179,7 +179,7 @@ tape( 'the function inserts singleton dimensions', function test( t ) {
179179
t.end();
180180
});
181181

182-
tape( 'the function inserts singleton dimensions (negative axis)', function test( t ) {
182+
tape( 'the function inserts singleton dimensions (negative index)', function test( t ) {
183183
var x;
184184
var y;
185185

@@ -217,7 +217,7 @@ tape( 'the function prepends singleton dimensions (base; row-major)', function t
217217
t.end();
218218
});
219219

220-
tape( 'the function prepends singleton dimensions (base; row-major; negative axis)', function test( t ) {
220+
tape( 'the function prepends singleton dimensions (base; row-major; negative index)', function test( t ) {
221221
var x;
222222
var y;
223223

@@ -277,7 +277,7 @@ tape( 'the function appends singleton dimensions (base; row-major)', function te
277277
t.end();
278278
});
279279

280-
tape( 'the function appends singleton dimensions (base; row-major; negative axis)', function test( t ) {
280+
tape( 'the function appends singleton dimensions (base; row-major; negative index)', function test( t ) {
281281
var x;
282282
var y;
283283

@@ -337,7 +337,7 @@ tape( 'the function inserts singleton dimensions (base; row-major)', function te
337337
t.end();
338338
});
339339

340-
tape( 'the function inserts singleton dimensions (base; row-major; negative axis)', function test( t ) {
340+
tape( 'the function inserts singleton dimensions (base; row-major; negative index)', function test( t ) {
341341
var x;
342342
var y;
343343

0 commit comments

Comments
 (0)