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
* @param {string} xdtype - first input ndarray data type
262
195
* @param {string} ydtype - second input ndarray data type
263
196
* @param {string} policy - output ndarray data type policy
264
-
* @throws {TypeError} second argument must be a recognized data type policy
265
-
* @throws {Error} unexpected error
197
+
* @throws {TypeError} third argument must be a recognized data type policy
198
+
* @throws {Error} must provide data types amenable to type promotion
266
199
* @returns {string} output ndarray data type
267
200
*
268
201
* @example
269
202
* var dt = resolve( 'float64', 'float32', 'complex_floating_point' );
270
203
* // returns <string>
271
204
*/
272
205
function resolve( xdtype, ydtype, policy ) {
273
-
var dt;
274
-
275
-
// Check for a policy mandating an explicit data type...
276
-
if ( isDataType( policy ) ) {
277
-
// When the policy is a specific data type, the output data type should always be the specified data type without consideration for the input data types:
278
-
return policy;
279
-
}
280
-
if ( policy === 'same' ) {
281
-
// When the policy is "same", we require that all data types (both input and output) be the same...
282
-
if ( xdtype !== ydtype ) {
283
-
throw new Error( format( 'invalid arguments. Unable to resolve an output data type. The output data type policy is "same" and yet the input data types are not equal. Data types: [%s, %s].', xdtype, ydtype ) );
return unaryOutputDataType( xdtype, policy ); // note: these policies are independent of the input data type, so it doesn't matter what data type we provide as the first argument
289
-
}
290
-
// For all other policies, we always apply type promotion rules...
291
-
dt = promotionRules( xdtype, ydtype );
292
-
if ( dt === null || dt === -1 ) {
293
-
throw new Error( format( 'invalid arguments. Unable to apply type promotion rules when resolving a data type to which the input data types can be safely cast. Data types: [%s, %s].', xdtype, ydtype ) );
294
-
}
295
-
// Resolve the output data type by treating this scenario as equivalent to passing the promoted data type as an input to a unary function...
0 commit comments