check if the numpy.dtype matches the type used in the code
333564
def check_argument_type(dtype, kernel_argument, i):
    """"""
    types_map = {"uint8": ["uchar", "unsigned char", "uint8_t"],
                 "int8": ["char", "int8_t"],
                 "uint16": ["ushort", "unsigned short", "uint16_t"],
                 "int16": ["short", "int16_t"],
                 "uint32": ["uint", "unsigned int", "uint32_t"],
                 "int32": ["int", "int32_t"],   #discrepancy between OpenCL and C here, long may be 32bits in C
                 "uint64": ["ulong", "unsigned long", "uint64_t"],
                 "int64": ["long", "int64_t"],
                 "float16": ["half"],
                 "float32": ["float"],
                 "float64": ["double"]}
    if dtype in types_map:
        return any([substr in kernel_argument for substr in types_map[dtype]])
    else:
        return False
405197
def dtyping(*args):
    
    args = list(args)

    for idx, arg in enumerate(args):

        if isinstance(arg, Poly):
            args[idx] = Poly

        elif isinstance(arg, numpy.generic):
            args[idx] = numpy.asarray(arg).dtype

        elif isinstance(arg, (float, int)):
            args[idx] = type(arg)

    for type_ in DATATYPES:
        if type_ in args:
            return type_

    raise ValueError(
        "dtypes not recognised " + str([str(_) for _ in args]))
410839
def is_array_type(type_):
    

    array_types = _get_types(Types.ARRAY)
    if is_typing_type(type_):
        return type_ in array_types or (
            hasattr(type_, "__origin__") and type_.__origin__ in array_types
        )
    return type_ in array_types
321538
def _setup_dtype(self):
        """"""
        if self._dtype is not None:
            return self._dtype

        dtype = []  # Convert struct data types to numpy data type
        for i, typ in enumerate(self.typlist):
            if typ in self.NUMPY_TYPE_MAP:
                dtype.append(('s' + str(i), self.byteorder +
                              self.NUMPY_TYPE_MAP[typ]))
            else:
                dtype.append(('s' + str(i), 'S' + str(typ)))
        dtype = np.dtype(dtype)
        self._dtype = dtype

        return self._dtype
675438
def is_int_type(val):
    """"""
    try:               # Python 2
        return isinstance(val, (int, long))
    except NameError:  # Python 3
        return isinstance(val, int)
389571
def parse_type(self, hdat, dataobj=None):
        '''
        
        '''
        try:    dataobj = dataobj.dataobj
        except Exception: pass
        dtype = np.asarray(dataobj).dtype if dataobj else self.default_type()
        if   hdat and 'type'  in hdat: dtype = np.dtype(hdat['type'])
        elif hdat and 'dtype' in hdat: dtype = np.dtype(hdat['dtype'])
        return dtype
658309
def is_datetime_like(dtype):
    
    return (np.issubdtype(dtype, np.datetime64) or
            np.issubdtype(dtype, np.timedelta64))
1361134
def is_number(dtype):
    """"""
    return is_float(dtype) or ('int' in dtype.name) or ('long' in dtype.name) \
           or ('short' in dtype.name)
728373
def dtype_for(t):
    
    if t in dtype_dict:
        return dtype_dict[t]
    return np.typeDict.get(t, t)
326068
def ensure_dtype_float(x, default=np.float64):
    

    """
    if isinstance(x, np.ndarray):
        if x.dtype.kind == 'f':
            return x
        elif x.dtype.kind == 'i':
            return x.astype(default)
        else:
            raise TypeError('x is of type '+str(x.dtype)+' that cannot be converted to float')
    else:
        raise TypeError('x is not an array')
686467
def coerce_to_dtypes(result, dtypes):
    
    if len(result) != len(dtypes):
        raise AssertionError("_coerce_to_dtypes requires equal len arrays")

    def conv(r, dtype):
        try:
            if isna(r):
                pass
            elif dtype == _NS_DTYPE:
                r = tslibs.Timestamp(r)
            elif dtype == _TD_DTYPE:
                r = tslibs.Timedelta(r)
            elif dtype == np.bool_:
                # messy. non 0/1 integers do not get converted.
                if is_integer(r) and r not in [0, 1]:
                    return int(r)
                r = bool(r)
            elif dtype.kind == 'f':
                r = float(r)
            elif dtype.kind == 'i':
                r = int(r)
        except Exception:
            pass

        return r

    return [conv(r, dtype) for r, dtype in zip(result, dtypes)]
745656
def is_np_compat():
    
    curr = ctypes.c_bool()
    check_call(_LIB.MXIsNumpyCompatible(ctypes.byref(curr)))
    return curr.value
1211065
def suits_with_dtype(mn, mx, dtype):
    
    type_info = np.iinfo(dtype)
    if mx <= type_info.max and mn >= type_info.min:
        return True
    else:
        return False
1193173
def _infer_dtype(array, name=None):
    
    if array.dtype.kind != 'O':
        raise TypeError('infer_type must be called on a dtype=object array')

    if array.size == 0:
        return np.dtype(float)

    element = array[(0,) * array.ndim]
    if isinstance(element, (bytes, str)):
        return strings.create_vlen_dtype(type(element))

    dtype = np.array(element).dtype
    if dtype.kind != 'O':
        return dtype

    raise ValueError('unable to infer dtype on variable {!r}; xarray '
                     'cannot serialize arbitrary Python objects'
                     .format(name))
1008758
function isTypedArray( v ) {
	var i;
	v = typeName( v );
	for ( i = 0; i < NAMES.length; i++ ) {
		if ( NAMES[ i ] === v ) {
			return true;
		}
	}
	return false;
}
1188565
def get_numpy_dtype(obj):
    """"""
    if ndarray is not FakeObject:
        # NumPy is available
        import numpy as np
        if isinstance(obj, np.generic) or isinstance(obj, np.ndarray):
        # Numpy scalars all inherit from np.generic.
        # Numpy arrays all inherit from np.ndarray.
        # If we check that we are certain we have one of these
        # types then we are less likely to generate an exception below.
            try:
                return obj.dtype.type
            except (AttributeError, RuntimeError):
                #  AttributeError: some NumPy objects have no dtype attribute
                #  RuntimeError: happens with NetCDF objects (Issue 998)
                return
462575
def contains_all(self, other):
        """"""
        dtype = getattr(other, 'dtype', None)
        if dtype is None:
            dtype = np.result_type(*other)
        return is_int_dtype(dtype)