Skip to content

Commit 31d17dc

Browse files
committed
Auto-generated commit
1 parent 9a0599e commit 31d17dc

File tree

12 files changed

+376
-42
lines changed

12 files changed

+376
-42
lines changed

CHANGELOG.md

Lines changed: 36 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-04-23)
7+
## Unreleased (2025-04-24)
88

99
<section class="packages">
1010

@@ -1170,6 +1170,26 @@ A total of 2 issues were closed in this release:
11701170

11711171
<!-- /.features -->
11721172

1173+
<section class="bug-fixes">
1174+
1175+
##### Bug Fixes
1176+
1177+
- [`ac10964`](https://github.com/stdlib-js/stdlib/commit/ac109649d1cfad63800282f0d509aff419bfeb33) - ensure correct table validation
1178+
1179+
</section>
1180+
1181+
<!-- /.bug-fixes -->
1182+
1183+
<section class="breaking-changes">
1184+
1185+
##### BREAKING CHANGES
1186+
1187+
- [`d287f8e`](https://github.com/stdlib-js/stdlib/commit/d287f8e4a80211270e9fa96e05a17d6d1a9d2655): modify dispatch table to support type signatures
1188+
1189+
</section>
1190+
1191+
<!-- /.breaking-changes -->
1192+
11731193
</details>
11741194

11751195
</section>
@@ -1192,6 +1212,16 @@ A total of 2 issues were closed in this release:
11921212

11931213
<!-- /.features -->
11941214

1215+
<section class="breaking-changes">
1216+
1217+
##### BREAKING CHANGES
1218+
1219+
- [`d4f8189`](https://github.com/stdlib-js/stdlib/commit/d4f8189e03d81f54c5483ffb016ca967a3888565): modify dispatch table to support type signatures
1220+
1221+
</section>
1222+
1223+
<!-- /.breaking-changes -->
1224+
11951225
</details>
11961226

11971227
</section>
@@ -1664,6 +1694,8 @@ This release closes the following issue:
16641694

16651695
### BREAKING CHANGES
16661696

1697+
- [`d4f8189`](https://github.com/stdlib-js/stdlib/commit/d4f8189e03d81f54c5483ffb016ca967a3888565): modify dispatch table to support type signatures
1698+
- [`d287f8e`](https://github.com/stdlib-js/stdlib/commit/d287f8e4a80211270e9fa96e05a17d6d1a9d2655): modify dispatch table to support type signatures
16671699
- [`2f0aa48`](https://github.com/stdlib-js/stdlib/commit/2f0aa48ef6d561779d4bd4c4a54fe00a5a26c0e1): remove `mulf` symbol
16681700

16691701
- To migrate, users should access the same symbol via the `number/float32/base` namespace.
@@ -1719,6 +1751,9 @@ A total of 14 people contributed to this release. Thank you to the following con
17191751

17201752
<details>
17211753

1754+
- [`ac10964`](https://github.com/stdlib-js/stdlib/commit/ac109649d1cfad63800282f0d509aff419bfeb33) - **fix:** ensure correct table validation _(by Athan Reines)_
1755+
- [`d4f8189`](https://github.com/stdlib-js/stdlib/commit/d4f8189e03d81f54c5483ffb016ca967a3888565) - **refactor:** modify dispatch table to support type signatures _(by Athan Reines)_
1756+
- [`d287f8e`](https://github.com/stdlib-js/stdlib/commit/d287f8e4a80211270e9fa96e05a17d6d1a9d2655) - **refactor:** modify dispatch table to support type signatures _(by Athan Reines)_
17221757
- [`db7d60b`](https://github.com/stdlib-js/stdlib/commit/db7d60b388d19ab8a4b537ec3445f3181ef270b7) - **feat:** add `ndarray/base/unary-strided1d-dispatch-factory` _(by Athan Reines)_
17231758
- [`3036ccc`](https://github.com/stdlib-js/stdlib/commit/3036cccd1db41f0093555d2b7c890bdbd6f07cdf) - **feat:** add `ndarray/base/unary-strided1d-dispatch` _(by Athan Reines)_
17241759
- [`9c1e5c9`](https://github.com/stdlib-js/stdlib/commit/9c1e5c9b5b87643d31668a7a0b9c009413fa4c05) - **feat:** add `ndarray/base/unary-reduce-strided1d-dispatch-factory` _(by Athan Reines)_

base/unary-strided1d-dispatch-factory/README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,19 @@ var policy = 'same';
5151
var unary = unaryStrided1dDispatchFactory( table, [ dtypes ], dtypes, policy );
5252
```
5353

54-
- **table**: strided function dispatch table. Must have a `'default'` property and a corresponding strided function. May have additional properties corresponding to specific data types and associated specialized strided functions.
54+
- strided function dispatch table. Must have the following properties:
55+
56+
- **default**: default strided function which should be invoked when provided ndarrays have data types which do not have a corresponding specialized implementation.
57+
58+
A dispatch table may have the following additional properties:
59+
60+
- **types**: one-dimensional list of ndarray data types describing specialized input and output ndarray argument signatures. Only the input and output ndarray argument data types should be specified. Additional ndarray argument data types should be omitted and are not considered during dispatch. The length of `types` must equal the number of strided functions specified by `fcns` multiplied by two (i.e., for every pair of input-output ndarray data types, there must be a corresponding strided function in `fcns`).
61+
- **fcns**: list of strided functions which are specific to specialized input and output ndarray argument signatures.
62+
5563
- **idtypes**: list containing lists of supported input data types for each input ndarray argument.
56-
- **odtypes**: list of supported input data types.
64+
65+
- **odtypes**: list of supported output data types.
66+
5767
- **policy**: output data type policy.
5868

5969
#### unary( x\[, ...args]\[, options] )
@@ -184,6 +194,16 @@ The function accepts the following options:
184194

185195
## Notes
186196

197+
- A strided function should have the following signature:
198+
199+
```text
200+
f( arrays )
201+
```
202+
203+
where
204+
205+
- **arrays**: array containing input and output ndarrays, along with any additional ndarray arguments.
206+
187207
- The output data type policy only applies to the function returned by `factory`. For the `assign` method, the output ndarray is allowed to have any data type.
188208
189209
</section>
@@ -194,11 +214,13 @@ The function accepts the following options:
194214
195215
## Examples
196216
197-
<!-- eslint-disable id-length, max-len -->
217+
<!-- eslint-disable id-length, max-len, array-element-newline -->
198218
199219
<!-- eslint no-undef: "error" -->
200220
201221
```javascript
222+
var dcumax = require( '@stdlib/stats/base/ndarray/dcumax' );
223+
var scumax = require( '@stdlib/stats/base/ndarray/scumax' );
202224
var base = require( '@stdlib/stats/base/ndarray/cumax' );
203225
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
204226
var dtypes = require( '@stdlib/ndarray/dtypes' );
@@ -216,6 +238,14 @@ var policy = 'same';
216238
217239
// Define a dispatch table:
218240
var table = {
241+
'types': [
242+
'float64', 'float64', // input, output
243+
'float32', 'float32' // input, output
244+
],
245+
'fcns': [
246+
dcumax,
247+
scumax
248+
],
219249
'default': base
220250
};
221251

base/unary-strided1d-dispatch-factory/docs/repl.txt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,29 @@
44

55
Parameters
66
----------
7-
table: Function
8-
Dispatch table containing strided functions.
7+
table: Object
8+
Dispatch table containing strided functions. The table object must have
9+
the following property:
10+
11+
- default: default strided function to invoke when provided ndarrays
12+
have data types which do not have a corresponding specialized
13+
implementation.
14+
15+
The table may having the following additional properties:
16+
17+
- types: one-dimensional list of ndarray data types describing
18+
specialized input and output ndarray argument signatures.
19+
- fcns: list of strided functions which are specific to specialized
20+
input and output ndarray argument signatures.
21+
22+
A strided function should have the following signature:
23+
24+
f( arrays )
25+
26+
where
27+
28+
- arrays: array containing input and output ndarrays, along with any
29+
additional ndarray arguments.
930

1031
idtypes: Array<Array<string>>
1132
List containing lists of supported input array data types for each input

base/unary-strided1d-dispatch-factory/docs/types/index.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@ interface BaseDispatchTable<T, U> {
8484
/**
8585
* Dispatch table.
8686
*/
87-
type DispatchTable<T, U> = {
87+
interface DispatchTable<T, U> extends BaseDispatchTable<T, U> {
8888
/**
89-
* Default strided function.
89+
* One-dimensional list of ndarray data types describing specialized input and output ndarray argument signatures.
9090
*/
91-
default: Unary<T, U> | UnaryWithAdditionalArrays<T, U>;
92-
} & {
91+
types: ArrayLike<DataType>;
92+
9393
/**
94-
* Strided functions specific to particular data types.
94+
* List of strided functions which are specific to specialized input and output ndarray argument signatures.
9595
*/
96-
[ K in DataType ]?: Unary<T, U> | UnaryWithAdditionalArrays<T, U>;
97-
};
96+
fcns: ArrayLike<Unary<T, U> | UnaryWithAdditionalArrays<T, U>>;
97+
}
9898

9999
/**
100100
* Interface for applying an operation to an ndarray.
@@ -247,7 +247,7 @@ interface UnaryFunction<T, U> {
247247
* var arr = ndarray2array( y );
248248
* // returns [ -1.0, 2.0, 2.0 ]
249249
*/
250-
declare function factory<T = unknown, U = unknown>( table: DispatchTable<T, U>, idtypes: ArrayLike<ArrayLike<DataType>>, odtypes: ArrayLike<DataType>, policy: OutputPolicy ): UnaryFunction<T, U>;
250+
declare function factory<T = unknown, U = unknown>( table: DispatchTable<T, U> | BaseDispatchTable<T, U>, idtypes: ArrayLike<ArrayLike<DataType>>, odtypes: ArrayLike<DataType>, policy: OutputPolicy ): UnaryFunction<T, U>;
251251

252252

253253
// EXPORTS //

base/unary-strided1d-dispatch-factory/examples/index.js

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

19+
/* eslint-disable array-element-newline */
20+
1921
'use strict';
2022

23+
var dcumax = require( '@stdlib/stats/base/ndarray/dcumax' );
24+
var scumax = require( '@stdlib/stats/base/ndarray/scumax' );
2125
var base = require( '@stdlib/stats/base/ndarray/cumax' );
2226
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2327
var dtypes = require( './../../../dtypes' );
@@ -35,6 +39,14 @@ var policy = 'same';
3539

3640
// Define a dispatch table:
3741
var table = {
42+
'types': [
43+
'float64', 'float64', // input, output
44+
'float32', 'float32' // input, output
45+
],
46+
'fcns': [
47+
dcumax,
48+
scumax
49+
],
3850
'default': base
3951
};
4052

base/unary-strided1d-dispatch-factory/lib/main.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ var UnaryStrided1dDispatch = require( './../../../base/unary-strided1d-dispatch'
2929
/**
3030
* Returns a function for applying a strided function a provided ndarray.
3131
*
32-
* @param {Object} table - dispatch table containing strided array functions
32+
* @param {Object} table - dispatch table
33+
* @param {Function} table.default - default strided function
34+
* @param {StringArray} [table.types] - one-dimensional list of ndarray data types describing specialized input and output ndarray argument signatures
35+
* @param {ArrayLikeObject<Function>} [table.fcns] - list of strided functions which are specific to specialized input and output ndarray argument signatures
3336
* @param {ArrayLikeObject<StringArray>} idtypes - list containing lists of supported input data types for each ndarray argument
3437
* @param {StringArray} odtypes - list of supported output data types
3538
* @param {string} policy - output data type policy
36-
* @throws {TypeError} first argument must be an object
39+
* @throws {TypeError} first argument must be an object having valid properties
3740
* @throws {TypeError} second argument must be an array containing arrays of supported data types
3841
* @throws {TypeError} third argument must be an array of supported data types
3942
* @throws {TypeError} fourth argument must be a supported output data type policy
43+
* @throws {Error} first argument must be an object having valid properties
4044
* @returns {Function} function for applying a strided function an ndarray
4145
*
4246
* @example

base/unary-strided1d-dispatch/README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var UnaryStrided1dDispatch = require( '@stdlib/ndarray/base/unary-strided1d-disp
3232

3333
#### UnaryStrided1dDispatch( table, idtypes, odtypes, policy )
3434

35-
Constructor for applying a strided function to an input ndarray.
35+
Returns an interface for applying a strided function to an input ndarray.
3636

3737
```javascript
3838
var base = require( '@stdlib/stats/base/ndarray/cumax' );
@@ -49,9 +49,19 @@ var unary = new UnaryStrided1dDispatch( table, [ dtypes ], dtypes, policy );
4949

5050
The constructor has the following parameters:
5151

52-
- **table**: strided function dispatch table. Must have a `'default'` property and a corresponding strided function. May have additional properties corresponding to specific data types and associated specialized strided functions.
52+
- **table**: strided function dispatch table. Must have the following properties:
53+
54+
- **default**: default strided function which should be invoked when provided ndarrays have data types which do not have a corresponding specialized implementation.
55+
56+
A dispatch table may have the following additional properties:
57+
58+
- **types**: one-dimensional list of ndarray data types describing specialized input and output ndarray argument signatures. Only the input and output ndarray argument data types should be specified. Additional ndarray argument data types should be omitted and are not considered during dispatch. The length of `types` must equal the number of strided functions specified by `fcns` multiplied by two (i.e., for every pair of input-output ndarray data types, there must be a corresponding strided function in `fcns`).
59+
- **fcns**: list of strided functions which are specific to specialized input and output ndarray argument signatures.
60+
5361
- **idtypes**: list containing lists of supported input data types for each input ndarray argument.
54-
- **odtypes**: list of supported input data types.
62+
63+
- **odtypes**: list of supported output data types.
64+
5565
- **policy**: output data type policy.
5666

5767
#### UnaryStrided1dDispatch.prototype.apply( x\[, ...args]\[, options] )
@@ -176,6 +186,16 @@ The function accepts the following options:
176186

177187
## Notes
178188

189+
- A strided function should have the following signature:
190+
191+
```text
192+
f( arrays )
193+
```
194+
195+
where
196+
197+
- **arrays**: array containing input and output ndarrays, along with any additional ndarray arguments.
198+
179199
- The output data type policy only applies to the `apply` method. For the `assign` method, the output ndarray is allowed to have any data type.
180200
181201
</section>
@@ -186,9 +206,13 @@ The function accepts the following options:
186206
187207
## Examples
188208
209+
<!-- eslint-disable array-element-newline -->
210+
189211
<!-- eslint no-undef: "error" -->
190212
191213
```javascript
214+
var dcumax = require( '@stdlib/stats/base/ndarray/dcumax' );
215+
var scumax = require( '@stdlib/stats/base/ndarray/scumax' );
192216
var base = require( '@stdlib/stats/base/ndarray/cumax' );
193217
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
194218
var dtypes = require( '@stdlib/ndarray/dtypes' );
@@ -206,6 +230,14 @@ var policy = 'same';
206230
207231
// Define a dispatch table:
208232
var table = {
233+
'types': [
234+
'float64', 'float64', // input, output
235+
'float32', 'float32' // input, output
236+
],
237+
'fcns': [
238+
dcumax,
239+
scumax
240+
],
209241
'default': base
210242
};
211243

base/unary-strided1d-dispatch/docs/repl.txt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
11

22
{{alias}}( table, idtypes, odtypes, policy )
3-
Constructor for applying a strided function to an input ndarray.
3+
Returns an ndarray function interface for applying a strided function to an
4+
input ndarray.
45

56
Parameters
67
----------
7-
table: Function
8-
Dispatch table containing strided functions.
8+
table: Object
9+
Dispatch table containing strided functions. The table object must have
10+
the following property:
11+
12+
- default: default strided function to invoke when provided ndarrays
13+
have data types which do not have a corresponding specialized
14+
implementation.
15+
16+
The table may having the following additional properties:
17+
18+
- types: one-dimensional list of ndarray data types describing
19+
specialized input and output ndarray argument signatures.
20+
- fcns: list of strided functions which are specific to specialized
21+
input and output ndarray argument signatures.
22+
23+
A strided function should have the following signature:
24+
25+
f( arrays )
26+
27+
where
28+
29+
- arrays: array containing input and output ndarrays, along with any
30+
additional ndarray arguments.
931

1032
idtypes: Array<Array<string>>
1133
List containing lists of supported input array data types for each input

0 commit comments

Comments
 (0)