def validate_dtype(termname, dtype, missing_value):
 if (dtype is NotSpecified):
  raise DTypeNotSpecified(termname=termname)
 try:
  dtype = dtype_class(dtype)
 except TypeError:
  raise NotDType(dtype=dtype, termname=termname)
 if (not can_represent_dtype(dtype)):
  raise UnsupportedDType(dtype=dtype, termname=termname)
 if (missing_value is NotSpecified):
  missing_value = default_missing_value_for_dtype(dtype)
 try:
  if (dtype == categorical_dtype):
   _assert_valid_categorical_missing_value(missing_value)
  array([missing_value]).astype(dtype=dtype, casting='same_kind')
 except TypeError as e:
  raise TypeError('Missing value {value!r} is not a valid choice for term {termname} with dtype {dtype}.\n\nCoercion attempt failed with: {error}'.format(termname=termname, value=missing_value, dtype=dtype, error=e))
 return (dtype, missing_value)

def validate_dtype ( termname , dtype , missing_value ) : if ( dtype is NotSpecified ) : raise DTypeNotSpecified ( termname = termname ) try : dtype = dtype_class ( dtype ) except TypeError : raise NotDType ( dtype = dtype , termname = termname ) if ( not can_represent_dtype ( dtype ) ) : raise UnsupportedDType ( dtype = dtype , termname = termname ) if ( missing_value is NotSpecified ) : missing_value = default_missing_value_for_dtype ( dtype ) try : if ( dtype == categorical_dtype ) : _assert_valid_categorical_missing_value ( missing_value ) array ( [ missing_value ] ) . astype ( dtype = dtype , casting = 'same_kind' ) except TypeError as e : raise TypeError ( 'Missing value {value!r} is not a valid choice for term {termname} with dtype {dtype}.\n\nCoercion attempt failed with: {error}' . format ( termname = termname , value = missing_value , dtype = dtype , error = e ) ) return ( dtype , missing_value )
validate a dtype and missing_value passed to term .