Skip to content

feat: update namespace TypeScript declarations #3916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ interface Namespace {
*
* @param N - number of indexed elements
* @param x - input array
* @param stride - stride length
* @param strideX - stride length
* @returns sum
*
* @example
Expand Down
155 changes: 155 additions & 0 deletions lib/node_modules/@stdlib/ndarray/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ import dtypes = require( '@stdlib/ndarray/dtypes' );
import empty = require( '@stdlib/ndarray/empty' );
import emptyLike = require( '@stdlib/ndarray/empty-like' );
import FancyArray = require( '@stdlib/ndarray/fancy' );
import filter = require( '@stdlib/ndarray/filter' );
import filterMap = require( '@stdlib/ndarray/filter-map' );
import flag = require( '@stdlib/ndarray/flag' );
import flags = require( '@stdlib/ndarray/flags' );
import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
import ind2sub = require( '@stdlib/ndarray/ind2sub' );
import indexModes = require( '@stdlib/ndarray/index-modes' );
import iter = require( '@stdlib/ndarray/iter' );
import map = require( '@stdlib/ndarray/map' );
import maybeBroadcastArray = require( '@stdlib/ndarray/maybe-broadcast-array' );
import maybeBroadcastArrays = require( '@stdlib/ndarray/maybe-broadcast-arrays' );
import minDataType = require( '@stdlib/ndarray/min-dtype' );
Expand All @@ -55,6 +58,7 @@ import order = require( '@stdlib/ndarray/order' );
import orders = require( '@stdlib/ndarray/orders' );
import outputDataTypePolicies = require( '@stdlib/ndarray/output-dtype-policies' );
import promotionRules = require( '@stdlib/ndarray/promotion-rules' );
import reject = require( '@stdlib/ndarray/reject' );
import safeCasts = require( '@stdlib/ndarray/safe-casts' );
import sameKindCasts = require( '@stdlib/ndarray/same-kind-casts' );
import shape = require( '@stdlib/ndarray/shape' );
Expand Down Expand Up @@ -563,6 +567,83 @@ interface Namespace {
*/
FancyArray: typeof FancyArray;

/**
* Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
*
* @param x - input ndarray
* @param options - options
* @param options.dtype - output ndarray data type
* @param options.order - iteration order
* @param predicate - predicate function
* @param thisArg - predicate function execution context
* @returns output ndarray
*
* @example
* var isEven = require( '@stdlib/assert/is-even' ).isPrimitive;
* var Float64Array = require( '@stdlib/array/float64' );
* var ndarray = require( '@stdlib/ndarray/ctor' );
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
*
* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
* var shape = [ 2, 3 ];
* var strides = [ 6, 1 ];
* var offset = 1;
*
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
* // returns <ndarray>
*
* var opts = {
* 'dtype': 'generic'
* };
* var y = ns.filter( x, opts, isEven );
* // returns <ndarray>
*
* var arr = ndarray2array( y );
* // returns [ 2.0, 4.0, 8.0, 10.0 ]
*/
filter: typeof filter;

/**
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
*
* @param x - input ndarray
* @param options - options
* @param options.dtype - output ndarray data type
* @param options.order - iteration order
* @param fcn - callback function
* @param thisArg - callback function execution context
* @returns output ndarray
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
* var ndarray = require( '@stdlib/ndarray/ctor' );
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
*
* function scale( z ) {
* if ( z > 5.0 ) {
* return z * 10.0;
* }
* }
*
* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
* var shape = [ 2, 3 ];
* var strides = [ 6, 1 ];
* var offset = 1;
*
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
* // returns <ndarray>
*
* var opts = {
* 'dtype': 'generic'
* };
* var y = ns.filterMap( x, opts, scale );
* // returns <ndarray>
*
* var arr = ndarray2array( y );
* // returns [ 80.0, 90.0, 100.0 ]
*/
filterMap: typeof filterMap;

/**
* Returns a specified flag for a provided ndarray.
*
Expand Down Expand Up @@ -693,6 +774,44 @@ interface Namespace {
*/
iter: typeof iter;

/**
* Applies a callback function to elements in an input ndarray and assigns results to elements in a new output ndarray.
*
* @param x - input ndarray
* @param options - options
* @param options.dtype - output ndarray data type
* @param fcn - callback function
* @param thisArg - callback function execution context
* @returns output ndarray
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
* var ndarray = require( '@stdlib/ndarray/ctor' );
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
*
* function scale( z ) {
* return z * 10.0;
* }
*
* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
* var shape = [ 2, 3 ];
* var strides = [ 6, 1 ];
* var offset = 1;
*
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
* // returns <ndarray>
*
* var opts = {
* 'dtype': 'generic'
* };
* var y = ns.map( x, opts, scale );
* // returns <ndarray>
*
* var arr = ndarray2array( y );
* // returns [ [ 20, 30, 40 ], [ 80, 90, 100 ] ]
*/
map: typeof map;

/**
* Broadcasts an ndarray to a specified shape if and only if the specified shape differs from the provided ndarray's shape.
*
Expand Down Expand Up @@ -1019,6 +1138,42 @@ interface Namespace {
*/
promotionRules: typeof promotionRules;

/**
* Returns a shallow copy of an ndarray containing only those elements which fail a test implemented by a predicate function.
*
* @param x - input ndarray
* @param options - options
* @param options.dtype - output ndarray data type
* @param options.order - iteration order
* @param predicate - predicate function
* @param thisArg - predicate function execution context
* @returns output ndarray
*
* @example
* var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive;
* var Float64Array = require( '@stdlib/array/float64' );
* var ndarray = require( '@stdlib/ndarray/ctor' );
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
*
* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
* var shape = [ 2, 3 ];
* var strides = [ 6, 1 ];
* var offset = 1;
*
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
* // returns <ndarray>
*
* var opts = {
* 'dtype': 'generic'
* };
* var y = ns.reject( x, opts, isOdd );
* // returns <ndarray>
*
* var arr = ndarray2array( y );
* // returns [ 2.0, 4.0, 8.0, 10.0 ]
*/
reject: typeof reject;

/**
* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast.
*
Expand Down
Loading