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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -674,6 +674,7 @@ A total of 37 issues were closed in this release:
674
674
675
675
<details>
676
676
677
+
-[`da7ea70`](https://github.com/stdlib-js/stdlib/commit/da7ea70b7b2de281c4c1364fe7dca3ef8ca7085c) - **refactor:** support data type instances _(by Athan Reines)_
@@ -192,10 +189,7 @@ declare class BinaryStrided1dDispatch<T, U> {
192
189
* var y = new ndarray( 'generic', ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
193
190
*
194
191
* var z = dot.apply( x, y );
195
-
* // returns <ndarray>
196
-
*
197
-
* var v = z.get();
198
-
* // returns -5.0
192
+
* // returns <ndarray>[ -5.0 ]
199
193
*/
200
194
apply(x: InputArray<T>,y: InputArray<T>, ...args: Array<InputArray<T>|Options>): OutputArray<U>;// NOTE: we lose type specificity here, but retaining specificity would likely be difficult and/or tedious to completely enumerate, as the output ndarray data type is dependent on how the input ndarrays interact with output data type policy and whether that policy has been overridden by `options.dtype`. In principle, as well, based on the policy, it is possible to know more exactly which `InputArray` types are actually allowed.
201
195
@@ -235,10 +229,7 @@ declare class BinaryStrided1dDispatch<T, U> {
235
229
* var z = new ndarray( 'generic', zbuf, [], [ 0 ], 0, 'row-major' );
236
230
*
237
231
* var out = dot.assign( x, y, z );
238
-
* // returns <ndarray>
239
-
*
240
-
* var v = out.get();
241
-
* // returns -5.0
232
+
* // returns <ndarray>[ -5.0 ]
242
233
*
243
234
* var bool = ( out === z );
244
235
* // returns true
@@ -281,10 +272,7 @@ declare class BinaryStrided1dDispatch<T, U> {
281
272
* var z = new ndarray( 'generic', zbuf, [], [ 0 ], 0, 'row-major' );
vargetShape=require('./../../../shape');// note: non-base accessor is intentional due to input ndarrays originating in userland
43
46
varndims=require('./../../../ndims');
@@ -74,10 +77,10 @@ var DEFAULT_ORDER = defaults.get( 'order' );
74
77
* @constructor
75
78
* @param {Object} table - dispatch table
76
79
* @param {Function} table.default - default strided reduction function
77
-
* @param {StringArray} [table.types=[]] - one-dimensional list of ndarray data types describing specialized input ndarray argument signatures
80
+
* @param {Array} [table.types=[]] - one-dimensional list of ndarray data types describing specialized input ndarray argument signatures
78
81
* @param {ArrayLikeObject<Function>} [table.fcns=[]] - list of strided reduction functions which are specific to specialized input ndarray argument signatures
79
-
* @param {ArrayLikeObject<StringArray>} idtypes - list containing lists of supported input data types for each input ndarray argument
80
-
* @param {StringArray} odtypes - list of supported output data types
82
+
* @param {ArrayLikeObject<Array>} idtypes - list containing lists of supported input data types for each input ndarray argument
83
+
* @param {Array} odtypes - list of supported output data types
81
84
* @param {Object} policies - policies
82
85
* @param {string} policies.output - output data type policy
@@ -264,11 +265,11 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
264
265
thrownewTypeError(format('invalid argument. Second argument must be an ndarray-like object. Value: `%s`.',y));
265
266
}
266
267
xdt=getDType(x);
267
-
if(!contains(this._idtypes[0],xdt)){
268
+
if(!contains(this._idtypes[0],resolveStr(xdt))){
268
269
thrownewTypeError(format('invalid argument. First argument must have one of the following data types: "%s". Data type: `%s`.',join(this._idtypes[0],'", "'),xdt));
269
270
}
270
271
ydt=getDType(y);
271
-
if(!contains(this._idtypes[1],ydt)){
272
+
if(!contains(this._idtypes[1],resolveStr(ydt))){
272
273
thrownewTypeError(format('invalid argument. Second argument must have one of the following data types: "%s". Data type: `%s`.',join(this._idtypes[1],'", "'),ydt));
273
274
}
274
275
args=[x,y];
@@ -278,7 +279,7 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
278
279
break;
279
280
}
280
281
dt=getDType(arr);
281
-
if(!contains(this._idtypes[i],dt)){
282
+
if(!contains(this._idtypes[i],resolveStr(dt))){
282
283
thrownewTypeError(format('invalid argument. Argument %d must have one of the following data types: "%s". Data type: `%s`.',i,join(this._idtypes[i],'", "'),dt));
283
284
}
284
285
// Note: we don't type promote additional ndarray arguments, as they are passed as scalars to the underlying strided reduction function...
@@ -337,15 +338,15 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
337
338
338
339
// Determine whether we need to cast the input ndarrays...
// TODO: replace the following logic with a call to `ndarray/base/(?maybe-)(cast|convert|copy)` or similar utility
350
351
tmp=baseEmpty(dt,shy,ordy);
351
352
assign([y,tmp]);
@@ -419,10 +420,7 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
419
420
* var z = new ndarray( 'generic', zbuf, [], [ 0 ], 0, 'row-major' );
420
421
*
421
422
* var out = dot.assign( x, y, z );
422
-
* // returns <ndarray>
423
-
*
424
-
* var v = out.get();
425
-
* // returns -5.0
423
+
* // returns <ndarray>[ -5.0 ]
426
424
*
427
425
* var bool = ( out === z );
428
426
* // returns true
@@ -457,11 +455,11 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'assign', function assign( x, y
457
455
}
458
456
// Validate the input ndarray data types in order to maintain similar behavior to `apply` above...
459
457
xdt=getDType(x);
460
-
if(!contains(this._idtypes[0],xdt)){
458
+
if(!contains(this._idtypes[0],resolveStr(xdt))){
461
459
thrownewTypeError(format('invalid argument. First argument must have one of the following data types: "%s". Data type: `%s`.',join(this._idtypes[0],'", "'),xdt));
462
460
}
463
461
ydt=getDType(y);
464
-
if(!contains(this._idtypes[1],ydt)){
462
+
if(!contains(this._idtypes[1],resolveStr(ydt))){
465
463
thrownewTypeError(format('invalid argument. Second argument must have one of the following data types: "%s". Data type: `%s`.',join(this._idtypes[1],'", "'),ydt));
466
464
}
467
465
// Verify that both input arrays have the same shape:
@@ -505,7 +503,7 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'assign', function assign( x, y
505
503
// 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; note: we don't type promote additional ndarray arguments, as they are passed as scalars to the underlying strided reduction function)...
506
504
for(i=2;i<args.length;i++){
507
505
dt=getDType(args[i]);
508
-
if(!contains(this._idtypes[i],dt)){
506
+
if(!contains(this._idtypes[i],resolveStr(dt))){
509
507
thrownewTypeError(format('invalid argument. Argument %d must have one of the following data types: "%s". Data type: `%s`.',i,join(this._idtypes[i],'", "'),dt));
510
508
}
511
509
}
@@ -525,15 +523,15 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'assign', function assign( x, y
525
523
// Determine whether we need to cast the input ndarrays...
0 commit comments