Skip to content

Commit b77641d

Browse files
authored
feat!: update ndarray/base TypeScript declarations
BREAKING CHANGE: add writable parameter to and always return a new ndarray in `removeSingletonDimensions` To migrate, in order to preserve prior writable behavior, users should set the final parameter equal to a boolean indicating whether the input ndarray is writable. If not, pass `false`; if yes, pass `true`. To preserve prior behavior in which the input ndarray is returned if it does not have singleton dimensions, use `maybeRemoveSingletonDimensions`. PR-URL: #10558 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 2db642e commit b77641d

File tree

1 file changed

+70
-24
lines changed
  • lib/node_modules/@stdlib/ndarray/base/docs/types

1 file changed

+70
-24
lines changed

lib/node_modules/@stdlib/ndarray/base/docs/types/index.d.ts

Lines changed: 70 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import any = require( '@stdlib/ndarray/base/any' );
2424
import anyBy = require( '@stdlib/ndarray/base/any-by' );
2525
import assert = require( '@stdlib/ndarray/base/assert' );
2626
import assign = require( '@stdlib/ndarray/base/assign' );
27+
import atleastnd = require( '@stdlib/ndarray/base/atleastnd' );
2728
import binary = require( '@stdlib/ndarray/base/binary' );
2829
import binaryInputCastingDataType = require( '@stdlib/ndarray/base/binary-input-casting-dtype' );
2930
import binaryLoopOrder = require( '@stdlib/ndarray/base/binary-loop-interchange-order' );
@@ -163,6 +164,7 @@ import toFlippedud = require( '@stdlib/ndarray/base/to-flippedud' );
163164
import toNormalizedIndices = require( '@stdlib/ndarray/base/to-normalized-indices' );
164165
import toReversed = require( '@stdlib/ndarray/base/to-reversed' );
165166
import toReversedDimension = require( '@stdlib/ndarray/base/to-reversed-dimension' );
167+
import toTransposed = require( '@stdlib/ndarray/base/to-transposed' );
166168
import toUniqueNormalizedIndices = require( '@stdlib/ndarray/base/to-unique-normalized-indices' );
167169
import transpose = require( '@stdlib/ndarray/base/transpose' );
168170
import unary = require( '@stdlib/ndarray/base/unary' );
@@ -180,6 +182,7 @@ import unaryReduceSubarrayBy = require( '@stdlib/ndarray/base/unary-reduce-subar
180182
import unaryStrided1dDispatch = require( '@stdlib/ndarray/base/unary-strided1d-dispatch' );
181183
import unaryStrided1dDispatchFactory = require( '@stdlib/ndarray/base/unary-strided1d-dispatch-factory' );
182184
import unaryBlockSize = require( '@stdlib/ndarray/base/unary-tiling-block-size' );
185+
import unflattenShape = require( '@stdlib/ndarray/base/unflatten-shape' );
183186
import vind2bind = require( '@stdlib/ndarray/base/vind2bind' );
184187
import wrapIndex = require( '@stdlib/ndarray/base/wrap-index' );
185188
import zeros = require( '@stdlib/ndarray/base/zeros' );
@@ -301,6 +304,27 @@ interface Namespace {
301304
*/
302305
assign: typeof assign;
303306

307+
/**
308+
* Converts a list of values (scalars and/or ndarrays) to ndarrays having at least a specified number of dimensions.
309+
*
310+
* @param ndims - minimum number of dimensions
311+
* @param arrays - array-like object containing a list of scalars and/or ndarrays
312+
* @returns an array of ndarrays
313+
*
314+
* @example
315+
* var array = require( '@stdlib/ndarray/array' );
316+
*
317+
* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] );
318+
* // returns <ndarray>[ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ]
319+
*
320+
* var y = array( [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] );
321+
* // returns <ndarray>[ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ]
322+
*
323+
* var out = ns.atleastnd( 3, [ x, y ] );
324+
* // returns [ <ndarray>, <ndarray> ]
325+
*/
326+
atleastnd: typeof atleastnd;
327+
304328
/**
305329
* Applies a binary callback to elements in input ndarrays and assigns results to elements in an output ndarray.
306330
*
@@ -3378,14 +3402,14 @@ interface Namespace {
33783402
quinaryBlockSize: typeof quinaryBlockSize;
33793403

33803404
/**
3381-
* Returns an array without singleton dimensions.
3405+
* Returns an ndarray without singleton dimensions.
33823406
*
33833407
* ## Notes
33843408
*
3385-
* - If a provided ndarray does not have any singleton dimensions, the function returns the provided ndarray unchanged.
3386-
* - If a provided ndarray does have singleton dimensions, the function returns a new ndarray view.
3409+
* - The function always returns a new ndarray instance even if the input ndarray does not contain any singleton dimensions.
33873410
*
33883411
* @param x - input array
3412+
* @param writable - boolean indicating whether a returned array should be writable
33893413
* @returns squeezed array
33903414
*
33913415
* @example
@@ -3394,28 +3418,10 @@ interface Namespace {
33943418
* var x = array( [ [ 1, 2 ], [ 3, 4 ] ], {
33953419
* 'ndmin': 5
33963420
* });
3397-
* // returns <ndarray>
3398-
*
3399-
* var shx = x.shape;
3400-
* // returns [ 1, 1, 1, 2, 2 ]
3401-
*
3402-
* var y = ns.removeSingletonDimensions( x );
3403-
* // returns <ndarray>
3404-
*
3405-
* var shy = y.shape;
3406-
* // returns [ 2, 2 ]
3407-
*
3408-
* var v = y.get( 0, 0 );
3409-
* // returns 1
3410-
*
3411-
* v = y.get( 0, 1 );
3412-
* // returns 2
3413-
*
3414-
* v = y.get( 1, 0 );
3415-
* // returns 3
3421+
* // returns <ndarray>[ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]
34163422
*
3417-
* v = y.get( 1, 1 );
3418-
* // returns 4
3423+
* var y = ns.removeSingletonDimensions( x, false );
3424+
* // returns <ndarray>[ [ 1, 2 ], [ 3, 4 ] ]
34193425
*/
34203426
removeSingletonDimensions: typeof removeSingletonDimensions;
34213427

@@ -4598,6 +4604,23 @@ interface Namespace {
45984604
*/
45994605
toReversedDimension: typeof toReversedDimension;
46004606

4607+
/**
4608+
* Returns a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed.
4609+
*
4610+
* @param x - input array
4611+
* @returns output ndarray
4612+
*
4613+
* @example
4614+
* var array = require( '@stdlib/ndarray/array' );
4615+
*
4616+
* var x = array( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] );
4617+
* // returns <ndarray>[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
4618+
*
4619+
* var out = ns.toTransposed( x );
4620+
* // returns <ndarray>[ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
4621+
*/
4622+
toTransposed: typeof toTransposed;
4623+
46014624
/**
46024625
* Returns a list of unique indices after normalizing to the interval `[0,max]`.
46034626
*
@@ -5198,6 +5221,29 @@ interface Namespace {
51985221
*/
51995222
unaryBlockSize: typeof unaryBlockSize;
52005223

5224+
/**
5225+
* Expands a dimension over multiple dimensions.
5226+
*
5227+
* @param shape - array shape
5228+
* @param dim - dimension to be unflattened
5229+
* @param sizes - new shape of the unflattened dimension
5230+
* @returns unflattened shape
5231+
*
5232+
* @example
5233+
* var sh = ns.unflattenShape( [ 6, 2, 1 ], 0, [ 3, 2 ] );
5234+
* // returns [ 3, 2, 2, 1 ]
5235+
*
5236+
* @example
5237+
* var o = [ 0, 0, 0, 0 ];
5238+
*
5239+
* var out = ns.unflattenShape.assign( [ 6, 2, 1 ], 0, [ 3, 2 ], o );
5240+
* // returns [ 3, 2, 2, 1 ]
5241+
*
5242+
* var bool = ( out === o );
5243+
* // returns true
5244+
*/
5245+
unflattenShape: typeof unflattenShape;
5246+
52015247
/**
52025248
* Converts a linear index in an array view to a linear index in an underlying data buffer.
52035249
*

0 commit comments

Comments
 (0)