You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -65,10 +67,10 @@ var validate = require( './validate.js' );
65
67
* @constructor
66
68
* @param {Object} table - dispatch table
67
69
* @param {Function} table.default - default strided function
68
-
* @param {StringArray} [table.types=[]] - one-dimensional list of ndarray data types describing specialized input and output ndarray argument signatures
70
+
* @param {ArrayLikeObject} [table.types=[]] - one-dimensional list of ndarray data types describing specialized input and output ndarray argument signatures
69
71
* @param {ArrayLikeObject<Function>} [table.fcns=[]] - list of strided functions which are specific to specialized input and output ndarray argument signatures
70
-
* @param {ArrayLikeObject<StringArray>} idtypes - list containing lists of supported input data types for each ndarray argument
71
-
* @param {StringArray} odtypes - list of supported output data types
72
+
* @param {ArrayLikeObject<ArrayLikeObject>} idtypes - list containing lists of supported input data types for each ndarray argument
73
+
* @param {ArrayLikeObject} odtypes - list of supported output data types
72
74
* @param {Object} policies - policies
73
75
* @param {string} policies.output - output data type policy
thrownewError('invalid argument. First argument specifies an unexpected number of types. A pair of input and output ndarray data types must be specified for each provided strided function.');
* @param {IntegerArray} [options.dims] - list of dimensions over which to perform an operation
195
-
* @param {string} [options.dtype] - output ndarray data type
203
+
* @param {*} [options.dtype] - output ndarray data type
196
204
* @throws {TypeError} first argument must be an ndarray-like object
197
205
* @throws {TypeError} options argument must be an object
198
206
* @throws {RangeError} dimension indices must not exceed input ndarray bounds
@@ -232,6 +240,7 @@ setReadOnly( UnaryStrided1dDispatch.prototype, 'apply', function apply( x ) {
232
240
varnargs;
233
241
varargs;
234
242
varopts;
243
+
varxdte;
235
244
varerr;
236
245
varshx;
237
246
vararr;
@@ -249,8 +258,9 @@ setReadOnly( UnaryStrided1dDispatch.prototype, 'apply', function apply( x ) {
249
258
thrownewTypeError(format('invalid argument. First argument must be an ndarray-like object. Value: `%s`.',x));
250
259
}
251
260
xdt=getDType(x);
252
-
if(!contains(this._idtypes[0],xdt)){
253
-
thrownewTypeError(format('invalid argument. First argument must have one of the following data types: "%s". Data type: `%s`.',join(this._idtypes[0],'", "'),xdt));
261
+
xdte=resolveEnum(xdt);
262
+
if(!contains(this._idtypes[0],xdte)){
263
+
thrownewTypeError(format('invalid argument. First argument must have one of the following data types: "%s". Data type: `%s`.',join(dtypes2strings(this._idtypes[0]),'", "'),xdt));
254
264
}
255
265
args=[x];
256
266
for(i=1;i<nargs;i++){
@@ -259,9 +269,10 @@ setReadOnly( UnaryStrided1dDispatch.prototype, 'apply', function apply( x ) {
259
269
break;
260
270
}
261
271
dt=getDType(arr);
262
-
if(!contains(this._idtypes[i],dt)){
263
-
thrownewTypeError(format('invalid argument. Argument %d must have one of the following data types: "%s". Data type: `%s`.',i,join(this._idtypes[i],'", "'),dt));
272
+
if(!contains(this._idtypes[i],resolveEnum(dt))){
273
+
thrownewTypeError(format('invalid argument. Argument %d must have one of the following data types: "%s". Data type: `%s`.',i,join(dtypes2strings(this._idtypes[i]),'", "'),dt));
264
274
}
275
+
// Note: we don't type promote additional ndarray arguments...
265
276
args.push(arr);
266
277
}
267
278
// If we didn't make it up until the last argument, this means that we found a non-options argument which was not an ndarray...
@@ -292,15 +303,15 @@ setReadOnly( UnaryStrided1dDispatch.prototype, 'apply', function apply( x ) {
292
303
293
304
// Determine whether we need to cast the input ndarray...
@@ -370,6 +381,7 @@ setReadOnly( UnaryStrided1dDispatch.prototype, 'assign', function assign( x ) {
370
381
varnargs;
371
382
varopts;
372
383
varargs;
384
+
varxdte;
373
385
vararr;
374
386
varerr;
375
387
varflg;
@@ -388,8 +400,9 @@ setReadOnly( UnaryStrided1dDispatch.prototype, 'assign', function assign( x ) {
388
400
}
389
401
// Validate the input ndarray data type in order to maintain similar behavior to `apply` above...
390
402
xdt=getDType(x);
391
-
if(!contains(this._idtypes[0],xdt)){
392
-
thrownewTypeError(format('invalid argument. First argument must have one of the following data types: "%s". Data type: `%s`.',join(this._idtypes[0],'", "'),xdt));
403
+
xdte=resolveEnum(xdt);
404
+
if(!contains(this._idtypes[0],xdte)){
405
+
thrownewTypeError(format('invalid argument. First argument must have one of the following data types: "%s". Data type: `%s`.',join(dtypes2strings(this._idtypes[0]),'", "'),xdt));
393
406
}
394
407
args=[x];
395
408
@@ -420,8 +433,8 @@ setReadOnly( UnaryStrided1dDispatch.prototype, 'assign', function assign( x ) {
420
433
// Verify that additional ndarray arguments have expected dtypes (note: we intentionally don't validate the output ndarray dtype in order to provide an escape hatch for a user wanting to have an output ndarray having a specific dtype that `apply` does not support)...
421
434
for(i=1;i<args.length;i++){
422
435
dt=getDType(args[i]);
423
-
if(!contains(this._idtypes[i],dt)){
424
-
thrownewTypeError(format('invalid argument. Argument %d must have one of the following data types: "%s". Data type: `%s`.',i,join(this._idtypes[i],'", "'),dt));
436
+
if(!contains(this._idtypes[i],resolveEnum(dt))){
437
+
thrownewTypeError(format('invalid argument. Argument %d must have one of the following data types: "%s". Data type: `%s`.',i,join(dtypes2strings(this._idtypes[i]),'", "'),dt));
425
438
}
426
439
}
427
440
// Validate any provided options...
@@ -440,15 +453,15 @@ setReadOnly( UnaryStrided1dDispatch.prototype, 'assign', function assign( x ) {
440
453
// Determine whether we need to cast the input ndarray...
returnnewTypeError(format('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.','dtype',join(dtypes,'", "'),opts.dtype));
82
+
if(!contains(dtypes,resolveEnum(opts.dtype))){
83
+
returnnewTypeError(format('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.','dtype',join(dtypes2strings(dtypes),'", "'),options.dtype));
0 commit comments