Skip to content

Commit cc6cfb2

Browse files
committed
Auto-generated commit
1 parent 79d5c10 commit cc6cfb2

File tree

8 files changed

+175
-2
lines changed

8 files changed

+175
-2
lines changed

CHANGELOG.md

Lines changed: 9 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-01-12)
7+
## Unreleased (2025-01-13)
88

99
<section class="packages">
1010

@@ -86,6 +86,7 @@
8686

8787
##### Features
8888

89+
- [`e661213`](https://github.com/stdlib-js/stdlib/commit/e66121352ef767cdb87d19e938b1eccf7970fa3a) - update namespace TypeScript declarations [(#4706)](https://github.com/stdlib-js/stdlib/pull/4706)
8990
- [`741b6f1`](https://github.com/stdlib-js/stdlib/commit/741b6f1df8ce11e77fb22c279cee6bbae3323176) - add `spreadDimensions` to namespace
9091
- [`908239e`](https://github.com/stdlib-js/stdlib/commit/908239e7cc6b4b3e260d0cc1f5aebb9af35d83c6) - add `toUniqueNormalizedIndices` to namespace
9192
- [`524e854`](https://github.com/stdlib-js/stdlib/commit/524e854202862d5b37d66470d719fac1270e33c1) - add `toNormalizedIndices` to namespace
@@ -129,6 +130,7 @@
129130

130131
##### Features
131132

133+
- [`e661213`](https://github.com/stdlib-js/stdlib/commit/e66121352ef767cdb87d19e938b1eccf7970fa3a) - update namespace TypeScript declarations [(#4706)](https://github.com/stdlib-js/stdlib/pull/4706)
132134
- [`a94dcea`](https://github.com/stdlib-js/stdlib/commit/a94dceaa9469c774ee4622567e4c15a15e215bcf) - add `isColumnMajorString` to namespace
133135
- [`5e1be08`](https://github.com/stdlib-js/stdlib/commit/5e1be08ff661fb981dc4a91c2e9d37d7396327f5) - add `isRowMajorString` to namespace
134136
- [`8b1548f`](https://github.com/stdlib-js/stdlib/commit/8b1548fb45c1ff131f5edac20cb984344a2d28ec) - update namespace TypeScript declarations [(#3190)](https://github.com/stdlib-js/stdlib/pull/3190)
@@ -754,6 +756,12 @@ A total of 3 people contributed to this release. Thank you to the following cont
754756

755757
<details>
756758

759+
- [`efe1f05`](https://github.com/stdlib-js/stdlib/commit/efe1f05049247502e9b124957755ebc6d7974b4e) - **docs:** add note _(by Athan Reines)_
760+
- [`fc93a7c`](https://github.com/stdlib-js/stdlib/commit/fc93a7c94279c57675c8fc695189200ec0129821) - **docs:** add note _(by Athan Reines)_
761+
- [`1634973`](https://github.com/stdlib-js/stdlib/commit/16349736f27970606eda37417f4d2c868d9f1457) - **docs:** add note _(by Athan Reines)_
762+
- [`2d758d2`](https://github.com/stdlib-js/stdlib/commit/2d758d2dbab56194af31b9d54988b5fb9b928860) - **docs:** add note _(by Athan Reines)_
763+
- [`705dd30`](https://github.com/stdlib-js/stdlib/commit/705dd302fe6448af5addcacf9215574da5473f31) - **docs:** update examples _(by Athan Reines)_
764+
- [`e661213`](https://github.com/stdlib-js/stdlib/commit/e66121352ef767cdb87d19e938b1eccf7970fa3a) - **feat:** update namespace TypeScript declarations [(#4706)](https://github.com/stdlib-js/stdlib/pull/4706) _(by stdlib-bot)_
757765
- [`cff470f`](https://github.com/stdlib-js/stdlib/commit/cff470f9608165100c8c122fce70c40b1af864ec) - **docs:** update namespace table of contents (#4708) _(by stdlib-bot, Planeshifter)_
758766
- [`741b6f1`](https://github.com/stdlib-js/stdlib/commit/741b6f1df8ce11e77fb22c279cee6bbae3323176) - **feat:** add `spreadDimensions` to namespace _(by Athan Reines)_
759767
- [`3767255`](https://github.com/stdlib-js/stdlib/commit/3767255c7cfe85f09cea5c007e21297cd628245d) - **feat:** add `ndarray/base/spread-dimensions` _(by Athan Reines)_

base/assert/docs/types/index.d.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import isBufferLengthCompatibleShape = require( './../../../../base/assert/is-bu
2828
import isCastingMode = require( './../../../../base/assert/is-casting-mode' );
2929
import isColumnMajor = require( './../../../../base/assert/is-column-major' );
3030
import isColumnMajorContiguous = require( './../../../../base/assert/is-column-major-contiguous' );
31+
import isColumnMajorString = require( './../../../../base/assert/is-column-major-string' );
3132
import isComplexFloatingPointDataType = require( './../../../../base/assert/is-complex-floating-point-data-type' );
3233
import isContiguous = require( './../../../../base/assert/is-contiguous' );
3334
import isDataType = require( './../../../../base/assert/is-data-type' );
@@ -42,6 +43,7 @@ import isRealDataType = require( './../../../../base/assert/is-real-data-type' )
4243
import isRealFloatingPointDataType = require( './../../../../base/assert/is-real-floating-point-data-type' );
4344
import isRowMajor = require( './../../../../base/assert/is-row-major' );
4445
import isRowMajorContiguous = require( './../../../../base/assert/is-row-major-contiguous' );
46+
import isRowMajorString = require( './../../../../base/assert/is-row-major-string' );
4547
import isSafeDataTypeCast = require( './../../../../base/assert/is-safe-data-type-cast' );
4648
import isSameKindDataTypeCast = require( './../../../../base/assert/is-same-kind-data-type-cast' );
4749
import isSignedIntegerDataType = require( './../../../../base/assert/is-signed-integer-data-type' );
@@ -262,6 +264,24 @@ interface Namespace {
262264
*/
263265
isColumnMajorContiguous: typeof isColumnMajorContiguous;
264266

267+
/**
268+
* Tests whether an input value is the string representing column-major order.
269+
*
270+
* @param v - value to test
271+
* @returns boolean result
272+
*
273+
* @example
274+
* var bool = ns.isColumnMajorString( 'column-major' );
275+
* // returns true
276+
*
277+
* bool = ns.isColumnMajorString( 'row-major' );
278+
* // returns false
279+
*
280+
* bool = ns.isColumnMajorString( 'foo' );
281+
* // returns false
282+
*/
283+
isColumnMajorString: typeof isColumnMajorString;
284+
265285
/**
266286
* Tests whether an input value is a supported ndarray complex-valued floating-point data type.
267287
*
@@ -747,6 +767,24 @@ interface Namespace {
747767
*/
748768
isRowMajorContiguous: typeof isRowMajorContiguous;
749769

770+
/**
771+
* Tests whether an input value is the string representing row-major order.
772+
*
773+
* @param v - value to test
774+
* @returns boolean result
775+
*
776+
* @example
777+
* var bool = ns.isRowMajorString( 'row-major' );
778+
* // returns true
779+
*
780+
* bool = ns.isRowMajorString( 'column-major' );
781+
* // returns false
782+
*
783+
* bool = ns.isRowMajorString( 'foo' );
784+
* // returns false
785+
*/
786+
isRowMajorString: typeof isRowMajorString;
787+
750788
/**
751789
* Returns a boolean indicating if a provided ndarray data type can be safely cast to another ndarray data type.
752790
*

base/docs/types/index.d.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import ndims = require( './../../../base/ndims' );
7676
import nextCartesianIndex = require( './../../../base/next-cartesian-index' );
7777
import nonsingletonDimensions = require( './../../../base/nonsingleton-dimensions' );
7878
import normalizeIndex = require( './../../../base/normalize-index' );
79+
import normalizeIndices = require( './../../../base/normalize-indices' );
7980
import nullary = require( './../../../base/nullary' );
8081
import nullaryLoopOrder = require( './../../../base/nullary-loop-interchange-order' );
8182
import nullaryBlockSize = require( './../../../base/nullary-tiling-block-size' );
@@ -102,13 +103,16 @@ import sliceDimensionFrom = require( './../../../base/slice-dimension-from' );
102103
import sliceDimensionTo = require( './../../../base/slice-dimension-to' );
103104
import sliceFrom = require( './../../../base/slice-from' );
104105
import sliceTo = require( './../../../base/slice-to' );
106+
import spreadDimensions = require( './../../../base/spread-dimensions' );
105107
import stride = require( './../../../base/stride' );
106108
import strides = require( './../../../base/strides' );
107109
import strides2offset = require( './../../../base/strides2offset' );
108110
import strides2order = require( './../../../base/strides2order' );
109111
import sub2ind = require( './../../../base/sub2ind' );
110112
import ndarray2array = require( './../../../base/to-array' );
113+
import toNormalizedIndices = require( './../../../base/to-normalized-indices' );
111114
import toReversed = require( './../../../base/to-reversed' );
115+
import toUniqueNormalizedIndices = require( './../../../base/to-unique-normalized-indices' );
112116
import transpose = require( './../../../base/transpose' );
113117
import unary = require( './../../../base/unary' );
114118
import unaryBy = require( './../../../base/unary-by' );
@@ -1865,6 +1869,27 @@ interface Namespace {
18651869
*/
18661870
normalizeIndex: typeof normalizeIndex;
18671871

1872+
/**
1873+
* Normalizes a list of indices to the interval `[0,max]`.
1874+
*
1875+
* ## Notes
1876+
*
1877+
* - If provided an out-of-bounds index, the function returns `null`.
1878+
* - The function mutates the input array, even when provided an out-of-bounds index.
1879+
*
1880+
* @param indices - indices
1881+
* @param max - maximum index
1882+
* @returns normalized indices or null
1883+
*
1884+
* @example
1885+
* var indices = ns.normalizeIndices( [ -2, 5 ], 10 );
1886+
* // returns [ 9, 5 ]
1887+
*
1888+
* indices = ns.normalizeIndices( [ -2, 15 ], 10 );
1889+
* // returns null
1890+
*/
1891+
normalizeIndices: typeof normalizeIndices;
1892+
18681893
/**
18691894
* Applies a nullary callback and assigns results to elements in an output ndarray.
18701895
*
@@ -2662,6 +2687,48 @@ interface Namespace {
26622687
*/
26632688
sliceTo: typeof sliceTo;
26642689

2690+
/**
2691+
* Expands the shape of an array to a specified dimensionality by spreading its dimensions to specified dimension indices and inserting dimensions of size one for the remaining dimensions.
2692+
*
2693+
* ## Notes
2694+
*
2695+
* - Each provided dimension index must reside on the interval `[-ndims, ndims-1]`. If provided a negative dimension index, the position at which to place a respective dimension is computed as `ndims + index`.
2696+
* - Provided dimension indices must resolve to normalized dimension indices arranged in ascending order.
2697+
*
2698+
* @param ndims - number of dimensions in the output array
2699+
* @param x - input array
2700+
* @param dims - dimension indices
2701+
* @returns output array
2702+
*
2703+
* @example
2704+
* var array = require( './../../../array' );
2705+
*
2706+
* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
2707+
* // returns <ndarray>
2708+
*
2709+
* var shx = x.shape;
2710+
* // returns [ 2, 2 ]
2711+
*
2712+
* var y = ns.spreadDimensions( 5, x, [ 1, 3 ] );
2713+
* // returns <ndarray>
2714+
*
2715+
* var shy = y.shape;
2716+
* // returns [ 1, 2, 1, 2, 1 ]
2717+
*
2718+
* var v = y.get( 0, 0, 0, 0, 0 );
2719+
* // returns 1
2720+
*
2721+
* v = y.get( 0, 0, 0, 1, 0 );
2722+
* // returns 2
2723+
*
2724+
* v = y.get( 0, 1, 0, 0, 0 );
2725+
* // returns 3
2726+
*
2727+
* v = y.get( 0, 1, 0, 1, 0 );
2728+
* // returns 4
2729+
*/
2730+
spreadDimensions: typeof spreadDimensions;
2731+
26652732
/**
26662733
* Returns the stride along a specified dimension for a provided ndarray.
26672734
*
@@ -2865,6 +2932,26 @@ interface Namespace {
28652932
*/
28662933
ndarray2array: typeof ndarray2array;
28672934

2935+
/**
2936+
* Normalizes a list of indices to the interval `[0,max]`.
2937+
*
2938+
* ## Notes
2939+
*
2940+
* - If provided an out-of-bounds index, the function normalizes the index to `-1`.
2941+
*
2942+
* @param indices - indices
2943+
* @param max - maximum index
2944+
* @returns normalized indices
2945+
*
2946+
* @example
2947+
* var indices = ns.toNormalizedIndices( [ -2, 5 ], 10 );
2948+
* // returns [ 9, 5 ]
2949+
*
2950+
* indices = ns.toNormalizedIndices( [ -2, 15 ], 10 );
2951+
* // returns [ 9, -1 ]
2952+
*/
2953+
toNormalizedIndices: typeof toNormalizedIndices;
2954+
28682955
/**
28692956
* Returns a new ndarray where the order of elements of an input ndarray is reversed along each dimension.
28702957
*
@@ -2901,6 +2988,26 @@ interface Namespace {
29012988
*/
29022989
toReversed: typeof toReversed;
29032990

2991+
/**
2992+
* Returns a list of unique indices after normalizing to the interval `[0,max]`.
2993+
*
2994+
* ## Notes
2995+
*
2996+
* - If provided an out-of-bounds index, the function returns `null`.
2997+
*
2998+
* @param indices - indices
2999+
* @param max - maximum index
3000+
* @returns normalized indices (or null)
3001+
*
3002+
* @example
3003+
* var indices = ns.toUniqueNormalizedIndices( [ -2, 5 ], 10 );
3004+
* // returns [ 9, 5 ]
3005+
*
3006+
* indices = ns.toUniqueNormalizedIndices( [ -2, 15 ], 10 );
3007+
* // returns null
3008+
*/
3009+
toUniqueNormalizedIndices: typeof toUniqueNormalizedIndices;
3010+
29043011
/**
29053012
* Transposes a matrix (or a stack of matrices).
29063013
*

base/normalize-index/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ idx = normalizeIndex( -15, 10 );
7070

7171
<section class="notes">
7272

73+
## Notes
74+
75+
- During normalization, a negative index is converted to a nonnegative index according to `max + idx + 1`. If, after normalization, the resolved index is still negative, the value is considered out-of-bounds.
76+
7377
</section>
7478

7579
<!-- /.notes -->

base/normalize-indices/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ var idx = normalizeIndices( [ 15, -15 ], 10 );
6767
## Notes
6868

6969
- The function mutates the input array, even when provided an out-of-bounds index. If mutation is undesired, copy the input array before calling this function.
70+
- During normalization, a negative index is converted to a nonnegative index according to `max + idx + 1`. If, after normalization, the resolved index is still negative, the value is considered out-of-bounds.
7071

7172
</section>
7273

base/spread-dimensions/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ var spreadDimensions = require( '@stdlib/ndarray/base/spread-dimensions' );
4545
Expands the shape of an array to a specified dimensionality by spreading its dimensions to specified dimension indices and inserting dimensions of size one for the remaining dimensions.
4646

4747
```javascript
48+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
4849
var array = require( '@stdlib/ndarray/array' );
4950

5051
// Create a 2x2 ndarray:
@@ -58,19 +59,28 @@ var y = spreadDimensions( 3, x, [ 1, 2 ] );
5859
var sh = y.shape;
5960
// returns [ 1, 2, 2 ]
6061

62+
var a = ndarray2array( y );
63+
// returns [ [ [ 1, 2 ], [ 3, 4 ] ] ]
64+
6165
// Append a singleton dimension:
6266
y = spreadDimensions( 3, x, [ 0, 1 ] );
6367
// returns <ndarray>
6468

6569
sh = y.shape;
6670
// returns [ 2, 2, 1 ]
6771

72+
a = ndarray2array( y );
73+
// returns [ [ [ 1 ], [ 2 ] ], [ [ 3 ], [ 4 ] ] ]
74+
6875
// Insert a singleton dimension:
6976
y = spreadDimensions( 3, x, [ 0, 2 ] );
7077
// returns <ndarray>
7178

7279
sh = y.shape;
7380
// returns [ 2, 1, 2 ]
81+
82+
a = ndarray2array( y );
83+
// returns [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]
7484
```
7585

7686
</section>

base/to-normalized-indices/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ var idx = toNormalizedIndices( [ 15, -15 ], 10 );
6464

6565
<section class="notes">
6666

67+
## Notes
68+
69+
- During normalization, a negative index is converted to a nonnegative index according to `max + idx + 1`. If, after normalization, the resolved index is still negative, the value is considered out-of-bounds.
70+
6771
</section>
6872

6973
<!-- /.notes -->

base/to-unique-normalized-indices/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ var idx = toUniqueNormalizedIndices( [ 15, -15 ], 10 );
6666

6767
## Notes
6868

69-
- The function preserves provided index order.
69+
- During normalization, a negative index is converted to a nonnegative index according to `max + idx + 1`. If, after normalization, the resolved index is still negative, the value is considered out-of-bounds.
7070
- When provided valid indices, the function always returns a "generic" array.
71+
- The function preserves provided index order.
7172

7273
</section>
7374

0 commit comments

Comments
 (0)