Skip to content

Commit 7faffe3

Browse files
stdlib-botkgryte
andauthored
feat: update namespace TypeScript declarations
PR-URL: stdlib-js#1122 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent de17736 commit 7faffe3

File tree

7 files changed

+1681
-15
lines changed

7 files changed

+1681
-15
lines changed

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

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import bbinary2d = require( '@stdlib/array/base/broadcasted-binary2d' );
3737
import bbinary3d = require( '@stdlib/array/base/broadcasted-binary3d' );
3838
import bbinary4d = require( '@stdlib/array/base/broadcasted-binary4d' );
3939
import bbinary5d = require( '@stdlib/array/base/broadcasted-binary5d' );
40+
import bternary2d = require( '@stdlib/array/base/broadcasted-ternary2d' );
4041
import bunary2d = require( '@stdlib/array/base/broadcasted-unary2d' );
4142
import bunary3d = require( '@stdlib/array/base/broadcasted-unary3d' );
4243
import bunary4d = require( '@stdlib/array/base/broadcasted-unary4d' );
@@ -86,6 +87,7 @@ import ones5d = require( '@stdlib/array/base/ones5d' );
8687
import onesnd = require( '@stdlib/array/base/onesnd' );
8788
import setter = require( '@stdlib/array/base/setter' );
8889
import take = require( '@stdlib/array/base/take' );
90+
import ternary2d = require( '@stdlib/array/base/ternary2d' );
8991
import toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
9092
import unary2d = require( '@stdlib/array/base/unary2d' );
9193
import unary2dBy = require( '@stdlib/array/base/unary2d-by' );
@@ -583,6 +585,44 @@ interface Namespace {
583585
*/
584586
bbinary5d: typeof bbinary5d;
585587

588+
/**
589+
* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a two-dimensional nested output array.
590+
*
591+
* ## Notes
592+
*
593+
* - The input array shapes must be broadcast compatible with the output array shape.
594+
*
595+
* @param arrays - array containing three input nested arrays and one output nested array
596+
* @param shapes - array shapes
597+
* @param fcn - ternary callback
598+
*
599+
* @example
600+
* var ones2d = require( `@stdlib/array/base/ones2d` );
601+
* var zeros2d = require( `@stdlib/array/base/zeros2d` );
602+
*
603+
* function add( x, y, z ) {
604+
* return x + y + z;
605+
* }
606+
*
607+
* var shapes = [
608+
* [ 1, 2 ],
609+
* [ 2, 1 ],
610+
* [ 1, 1 ],
611+
* [ 2, 2 ]
612+
* ];
613+
*
614+
* var x = ones2d( shapes[ 0 ] );
615+
* var y = ones2d( shapes[ 1 ] );
616+
* var z = ones2d( shapes[ 2 ] );
617+
* var out = zeros2d( shapes[ 3 ] );
618+
*
619+
* ns.bternary2d( [ x, y, z, out ], shapes, add );
620+
*
621+
* console.log( out );
622+
* // => [ [ 3.0, 6.0 ], [ 9.0, 12.0 ] ]
623+
*/
624+
bternary2d: typeof bternary2d;
625+
586626
/**
587627
* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a two-dimensional nested output array.
588628
*
@@ -1627,6 +1667,39 @@ interface Namespace {
16271667
*/
16281668
take: typeof take;
16291669

1670+
/**
1671+
* Applies a ternary callback to elements in three two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array.
1672+
*
1673+
* ## Notes
1674+
*
1675+
* - The function assumes that the input and output arrays have the same shape.
1676+
*
1677+
* @param arrays - array containing three input nested arrays and one output nested array
1678+
* @param shape - array shape
1679+
* @param fcn - ternary callback
1680+
*
1681+
* @example
1682+
* var ones2d = require( `@stdlib/array/base/ones2d` );
1683+
* var zeros2d = require( `@stdlib/array/base/zeros2d` );
1684+
*
1685+
* function add( x, y, z ) {
1686+
* return x + y + z;
1687+
* }
1688+
*
1689+
* var shape = [ 2, 2 ];
1690+
*
1691+
* var x = ones2d( shape );
1692+
* var y = ones2d( shape );
1693+
* var z = ones2d( shape );
1694+
* var out = zeros2d( shape );
1695+
*
1696+
* ns.ternary2d( [ x, y, z, out ], shape, add );
1697+
*
1698+
* console.log( out );
1699+
* // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ]
1700+
*/
1701+
ternary2d: typeof ternary2d;
1702+
16301703
/**
16311704
* Converts an array-like object to a minimal array-like object supporting the accessor protocol.
16321705
*

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import isDataType = require( '@stdlib/ndarray/base/assert/is-data-type' );
3333
import isFloatingPointDataType = require( '@stdlib/ndarray/base/assert/is-floating-point-data-type' );
3434
import isIndexMode = require( '@stdlib/ndarray/base/assert/is-index-mode' );
3535
import isIntegerDataType = require( '@stdlib/ndarray/base/assert/is-integer-data-type' );
36+
import isMostlySafeDataTypeCast = require( '@stdlib/ndarray/base/assert/is-mostly-safe-data-type-cast' );
3637
import isNumericDataType = require( '@stdlib/ndarray/base/assert/is-numeric-data-type' );
3738
import isOrder = require( '@stdlib/ndarray/base/assert/is-order' );
3839
import isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' );
@@ -131,6 +132,9 @@ interface Namespace {
131132
* bool = ns.isCastingMode( 'safe' );
132133
* // returns true
133134
*
135+
* bool = ns.isCastingMode( 'mostly-safe' );
136+
* // returns true
137+
*
134138
* bool = ns.isCastingMode( 'same-kind' );
135139
* // returns true
136140
*
@@ -432,6 +436,22 @@ interface Namespace {
432436
*/
433437
isIntegerDataType: typeof isIntegerDataType;
434438

439+
/**
440+
* Returns a boolean indicating if a provided ndarray data type can be safely cast or, for floating-point data types, downcast to another ndarray data type.
441+
*
442+
* @param from - ndarray data type
443+
* @param to - ndarray data type
444+
* @returns boolean indicating if a data type can be cast to another data type
445+
*
446+
* @example
447+
* var bool = ns.isMostlySafeDataTypeCast( 'float32', 'float64' );
448+
* // returns true
449+
*
450+
* bool = ns.isMostlySafeDataTypeCast( 'float64', 'int32' );
451+
* // returns false
452+
*/
453+
isMostlySafeDataTypeCast: typeof isMostlySafeDataTypeCast;
454+
435455
/**
436456
* Tests whether an input value is a supported ndarray numeric data type.
437457
*

0 commit comments

Comments
 (0)