Skip to content

Commit 7d00163

Browse files
committed
Auto-generated commit
1 parent c0dfc71 commit 7d00163

File tree

23 files changed

+326
-384
lines changed

23 files changed

+326
-384
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-12-29)
7+
## Unreleased (2025-12-30)
88

99
<section class="features">
1010

@@ -675,6 +675,9 @@ A total of 37 issues were closed in this release:
675675

676676
<details>
677677

678+
- [`dcc971a`](https://github.com/stdlib-js/stdlib/commit/dcc971a838258413c22944447da8c6cd1c2a63f3) - **docs:** update examples and use accessor functions _(by Athan Reines)_
679+
- [`16ce439`](https://github.com/stdlib-js/stdlib/commit/16ce439eb07c2a3212008ed9d2f5f6848da200f1) - **refactor:** update examples and return the input ndarray _(by Athan Reines)_
680+
- [`508b9b9`](https://github.com/stdlib-js/stdlib/commit/508b9b99fc2547eb50be79ade7f68a34c5fd2146) - **docs:** update examples and use accessor functions _(by Athan Reines)_
678681
- [`11b2d44`](https://github.com/stdlib-js/stdlib/commit/11b2d445b8f91c8bf41e3c6cc9d53d6a3a9f0608) - **refactor:** ensure support for enumeration constants _(by Athan Reines)_
679682
- [`7c5881e`](https://github.com/stdlib-js/stdlib/commit/7c5881ea1b0a9251b4b758d24df128a4fab28fa6) - **docs:** update dtype type _(by Athan Reines)_
680683
- [`374beff`](https://github.com/stdlib-js/stdlib/commit/374beff1f47c81bea4dd825d3b25ce405c2f9375) - **docs:** update dtype type _(by Athan Reines)_

base/expand-dimensions/README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,32 @@ var expandDimensions = require( '@stdlib/ndarray/base/expand-dimensions' );
4545
Expands the shape of an array `x` by inserting a new dimension of size one at a specified `axis`.
4646

4747
```javascript
48+
var getShape = require( '@stdlib/ndarray/shape' );
4849
var array = require( '@stdlib/ndarray/array' );
4950

5051
// Create a 2x2 ndarray:
5152
var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
52-
// returns <ndarray>
53+
// returns <ndarray>[ [ 1, 2 ], [ 3, 4 ] ]
5354

5455
// Prepend a singleton dimension:
5556
var y = expandDimensions( x, 0 );
56-
// returns <ndarray>
57+
// returns <ndarray>[ [ [ 1, 2 ], [ 3, 4 ] ] ]
5758

58-
var sh = y.shape;
59+
var sh = getShape( y );
5960
// returns [ 1, 2, 2 ]
6061

6162
// Append a singleton dimension:
6263
y = expandDimensions( x, 2 );
63-
// returns <ndarray>
64+
// returns <ndarray>[ [ [ 1 ], [ 2 ] ], [ [ 3 ], [ 4 ] ] ]
6465

65-
sh = y.shape;
66+
sh = getShape( y );
6667
// returns [ 2, 2, 1 ]
6768

6869
// Insert a singleton dimension:
6970
y = expandDimensions( x, 1 );
70-
// returns <ndarray>
71+
// returns <ndarray>[ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]
7172

72-
sh = y.shape;
73+
sh = getShape( y );
7374
// returns [ 2, 1, 2 ]
7475
```
7576

@@ -101,6 +102,7 @@ sh = y.shape;
101102
var array = require( '@stdlib/ndarray/array' );
102103
var numel = require( '@stdlib/ndarray/base/numel' );
103104
var ind2sub = require( '@stdlib/ndarray/ind2sub' );
105+
var getShape = require( '@stdlib/ndarray/shape' );
104106
var expandDimensions = require( '@stdlib/ndarray/base/expand-dimensions' );
105107

106108
// Create a 2-dimensional array:
@@ -112,7 +114,7 @@ var y = expandDimensions( x, 1 );
112114
// returns <ndarray>
113115

114116
// Retrieve the shape:
115-
var sh = y.shape;
117+
var sh = getShape( y );
116118
// returns [ 2, 1, 2 ]
117119

118120
// Retrieve the number of elements:

base/expand-dimensions/docs/repl.txt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,13 @@
2727
Examples
2828
--------
2929
> var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] )
30-
<ndarray>
31-
> var sh = x.shape
30+
<ndarray>[ [ 1, 2 ], [ 3, 4 ] ]
31+
> var sh = {{alias:@stdlib/ndarray/shape}}( x )
3232
[ 2, 2 ]
3333
> var y = {{alias}}( x, 1 )
34-
<ndarray>
35-
> sh = y.shape
34+
<ndarray>[ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]
35+
> sh = {{alias:@stdlib/ndarray/shape}}( y )
3636
[ 2, 1, 2 ]
37-
> var v = y.get( 0, 0, 0 )
38-
1
39-
> v = y.get( 0, 0, 1 )
40-
2
41-
> v = y.get( 1, 0, 0 )
42-
3
43-
> v = y.get( 1, 0, 1 )
44-
4
4537

4638
See Also
4739
--------

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

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { ndarray } from '@stdlib/types/ndarray';
23+
import { typedndarray } from '@stdlib/types/ndarray';
2424

2525
/**
2626
* Expands the shape of an array by inserting a new dimension of size one at a specified axis.
@@ -34,33 +34,22 @@ import { ndarray } from '@stdlib/types/ndarray';
3434
* @returns output array
3535
*
3636
* @example
37+
* var getShape = require( '@stdlib/ndarray/shape' );
3738
* var array = require( '@stdlib/ndarray/array' );
3839
*
3940
* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
40-
* // returns <ndarray>
41+
* // returns <ndarray>[ [ 1, 2 ], [ 3, 4 ] ]
4142
*
42-
* var shx = x.shape;
43+
* var shx = getShape( x );
4344
* // returns [ 2, 2 ]
4445
*
4546
* var y = expandDimensions( x, 1 );
46-
* // returns <ndarray>
47+
* // returns <ndarray>[ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]
4748
*
48-
* var shy = y.shape;
49+
* var shy = getShape( y );
4950
* // returns [ 2, 1, 2 ]
50-
*
51-
* var v = y.get( 0, 0, 0 );
52-
* // returns 1
53-
*
54-
* v = y.get( 0, 0, 1 );
55-
* // returns 2
56-
*
57-
* v = y.get( 1, 0, 0 );
58-
* // returns 3
59-
*
60-
* v = y.get( 1, 0, 1 );
61-
* // returns 4
6251
*/
63-
declare function expandDimensions( x: ndarray, axis: number ): ndarray;
52+
declare function expandDimensions<T = unknown>( x: typedndarray<T>, axis: number ): typedndarray<T>;
6453

6554

6655
// EXPORTS //

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

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

19-
import array = require( './../../../../array' );
19+
import zeros = require( './../../../../zeros' );
2020
import expandDimensions = require( './index' );
2121

2222

2323
// TESTS //
2424

2525
// The function returns an ndarray...
2626
{
27-
const x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
27+
const x = zeros( [ 2, 2 ] );
2828

29-
expandDimensions( x, 1 ); // $ExpectType ndarray
29+
expandDimensions( x, 1 ); // $ExpectType typedndarray<number>
3030
}
3131

3232
// The compiler throws an error if the function is not provided a first argument which is an ndarray...
@@ -43,7 +43,7 @@ import expandDimensions = require( './index' );
4343

4444
// The compiler throws an error if the function is not provided a second argument which is a number...
4545
{
46-
const x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
46+
const x = zeros( [ 2, 2 ] );
4747

4848
expandDimensions( x, '5' ); // $ExpectError
4949
expandDimensions( x, true ); // $ExpectError
@@ -56,7 +56,7 @@ import expandDimensions = require( './index' );
5656

5757
// The compiler throws an error if the function is provided an unsupported number of arguments...
5858
{
59-
const x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
59+
const x = zeros( [ 2, 2 ] );
6060

6161
expandDimensions(); // $ExpectError
6262
expandDimensions( x ); // $ExpectError

base/expand-dimensions/examples/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
var array = require( './../../../array' );
2222
var numel = require( './../../../base/numel' );
2323
var ind2sub = require( './../../../ind2sub' );
24+
var getShape = require( './../../../shape' );
2425
var expandDimensions = require( './../lib' );
2526

2627
// Create a 2-dimensional array:
@@ -32,7 +33,7 @@ var y = expandDimensions( x, 1 );
3233
// returns <ndarray>
3334

3435
// Retrieve the shape:
35-
var sh = y.shape;
36+
var sh = getShape( y );
3637
// returns [ 2, 1, 2 ]
3738

3839
// Retrieve the number of elements:

base/expand-dimensions/lib/index.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,21 @@
2424
* @module @stdlib/ndarray/base/expand-dimensions
2525
*
2626
* @example
27+
* var getShape = require( '@stdlib/ndarray/shape' );
2728
* var array = require( '@stdlib/ndarray/array' );
2829
* var expandDimensions = require( '@stdlib/ndarray/base/expand-dimensions' );
2930
*
3031
* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
31-
* // returns <ndarray>
32+
* // returns <ndarray>[ [ 1, 2 ], [ 3, 4 ] ]
3233
*
33-
* var shx = x.shape;
34+
* var shx = getShape( x );
3435
* // returns [ 2, 2 ]
3536
*
3637
* var y = expandDimensions( x, 1 );
37-
* // returns <ndarray>
38+
* // returns <ndarray>[ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]
3839
*
39-
* var shy = y.shape;
40+
* var shy = getShape( y );
4041
* // returns [ 2, 1, 2 ]
41-
*
42-
* var v = y.get( 0, 0, 0 );
43-
* // returns 1
44-
*
45-
* v = y.get( 0, 0, 1 );
46-
* // returns 2
47-
*
48-
* v = y.get( 1, 0, 0 );
49-
* // returns 3
50-
*
51-
* v = y.get( 1, 0, 1 );
52-
* // returns 4
5342
*/
5443

5544
// MODULES //

base/expand-dimensions/lib/main.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,20 @@ var format = require( '@stdlib/string/format' );
4747
* @returns {ndarray} output array
4848
*
4949
* @example
50+
* var getShape = require( '@stdlib/ndarray/shape' );
5051
* var array = require( '@stdlib/ndarray/array' );
5152
*
5253
* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
53-
* // returns <ndarray>
54+
* // returns <ndarray>[ [ 1, 2 ], [ 3, 4 ] ]
5455
*
55-
* var shx = x.shape;
56+
* var shx = getShape( x );
5657
* // returns [ 2, 2 ]
5758
*
5859
* var y = expandDimensions( x, 1 );
59-
* // returns <ndarray>
60+
* // returns <ndarray>[ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]
6061
*
61-
* var shy = y.shape;
62+
* var shy = getShape( y );
6263
* // returns [ 2, 1, 2 ]
63-
*
64-
* var v = y.get( 0, 0, 0 );
65-
* // returns 1
66-
*
67-
* v = y.get( 0, 0, 1 );
68-
* // returns 2
69-
*
70-
* v = y.get( 1, 0, 0 );
71-
* // returns 3
72-
*
73-
* v = y.get( 1, 0, 1 );
74-
* // returns 4
7564
*/
7665
function expandDimensions( x, axis ) {
7766
var strides;

0 commit comments

Comments
 (0)