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
@@ -34,45 +31,16 @@ var format = require( '@stdlib/string/format' );
34
31
* @param {string} xdtype - first input ndarray data type
35
32
* @param {string} ydtype - second input ndarray data type
36
33
* @param {string} policy - output ndarray data type policy
37
-
* @throws {TypeError} second argument must be a recognized data type policy
38
-
* @throws {Error} unexpected error
34
+
* @throws {TypeError} third argument must be a recognized data type policy
35
+
* @throws {Error} must provide data types amenable to type promotion
39
36
* @returns {string} output ndarray data type
40
37
*
41
38
* @example
42
39
* var dt = resolve( 'float64', 'float32', 'complex_floating_point' );
43
40
* // returns <string>
44
41
*/
45
42
functionresolve(xdtype,ydtype,policy){
46
-
vardt;
47
-
48
-
// Check for a policy mandating an explicit data type...
49
-
if(isDataType(policy)){
50
-
// 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:
51
-
returnpolicy;
52
-
}
53
-
if(policy==='same'){
54
-
// When the policy is "same", we require that all data types (both input and output) be the same...
55
-
if(xdtype!==ydtype){
56
-
thrownewError(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));
57
-
}
58
-
returnxdtype;
59
-
}
60
-
if(policy==='default'||policy==='default_index'){
61
-
returnunaryOutputDataType(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
62
-
}
63
-
// For all other policies, we always apply type promotion rules...
64
-
dt=promotionRules(xdtype,ydtype);
65
-
if(dt===null||dt===-1){
66
-
thrownewError(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));
67
-
}
68
-
// Resolve the output data type by treating this scenario as equivalent to passing the promoted data type as an input to a unary function...
69
-
try{
70
-
dt=unaryOutputDataType(dt,policy);
71
-
}catch(err){// eslint-disable-line no-unused-vars
72
-
// We should only get here if the policy is invalid...
73
-
thrownewTypeError(format('invalid argument. Third argument must be a supported data type policy. Value: `%s`.',policy));
0 commit comments