def getdtype(dtype, a=None, default=None):
<EOL>canCast = True<EOL>if dtype is None:<EOL><INDENT>try:<EOL><INDENT>newdtype = a.dtype<EOL><DEDENT>except AttributeError:<EOL><INDENT>if default is not None:<EOL><INDENT>newdtype = np.dtype(default)<EOL>canCast = False<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>newdtype = np.dtype(dtype)<EOL>if newdtype == np.object_:<EOL><INDENT>warnings.warn("<STR_LIT>")<EOL><DEDENT><DEDENT>return newdtype<EOL>
Function used to simplify argument processing.  If 'dtype' is not
    specified (is None), returns a.dtype; otherwise returns a np.dtype
    object created from the specified dtype argument.  If 'dtype' and 'a'
    are both None, construct a data type out of the 'default' parameter.
    Furthermore, 'dtype' must be in 'allowed' set.