Convert data from typeA to typeB (only numeric data types)
962088
def _cast(ins):
    
    # Signed and unsigned types are the same in the Z80
    tA = ins.quad[2]  # From TypeA
    tB = ins.quad[3]  # To TypeB

    YY_TYPES[tA]  # Type sizes
    xsB = sB = YY_TYPES[tB]  # Type sizes

    output = []
    if tA in ('u8', 'i8'):
        output.extend(_8bit_oper(ins.quad[4]))
    elif tA in ('u16', 'i16'):
        output.extend(_16bit_oper(ins.quad[4]))
    elif tA in ('u32', 'i32'):
        output.extend(_32bit_oper(ins.quad[4]))
    elif tA == 'f16':
        output.extend(_f16_oper(ins.quad[4]))
    elif tA == 'f':
        output.extend(_float_oper(ins.quad[4]))
    else:
        raise errors.GenericError(
            'Internal error: invalid typecast from %s to %s' % (tA, tB))

    if tB in ('u8', 'i8'):  # It was a byte
        output.extend(to_byte(tA))
    elif tB in ('u16', 'i16'):
        output.extend(to_word(tA))
    elif tB in ('u32', 'i32'):
        output.extend(to_long(tA))
    elif tB == 'f16':
        output.extend(to_fixed(tA))
    elif tB == 'f':
        output.extend(to_float(tA))

    xsB += sB % 2  # make it even (round up)

    if xsB > 4:
        output.extend(_fpush())
    else:
        if xsB > 2:
            output.append('push de')  # Fixed or 32 bit Integer

        if sB > 1:
            output.append('push hl')  # 16 bit Integer
        else:
            output.append('push af')  # 8 bit Integer

    return output
740522
def convert_type(self, value, spec):
        
        data_type = spec.get('type', 'string').lower().strip()
        if data_type in ['bool', 'boolean']:
            return value.lower() in BOOL_TRUISH
        elif data_type in ['int', 'integer']:
            try:
                return int(value)
            except (ValueError, TypeError):
                return None
        elif data_type in ['float', 'decimal', 'real']:
            try:
                return float(value)
            except (ValueError, TypeError):
                return None
        elif data_type in ['date', 'datetime', 'timestamp']:
            if 'format' in spec:
                format_list = self._get_date_format_list(spec.get('format'))
                if format_list is None:
                    raise MappingException(
                        '%s format mapping is not valid: %r' %
                        (spec.get('column'), spec.get('format'))
                    )
                for format, precision in format_list:
                    try:
                        return {'value': datetime.strptime(value, format),
                                'value_precision': precision}
                    except (ValueError, TypeError):
                        pass
                return None
            else:
                try:
                    return parser.parse(value)
                except (ValueError, TypeError):
                    return None
        elif data_type == 'file':
            try:
                return self._get_file(value)
            except:
                raise
        return value
774858
def fromNumpy(cls, data):
        
        assert np is not None
        if isinstance(data, np.ndarray):
            index = []
            if len(data.shape) == 1:
                columns = [('value', data.tolist())]
            elif len(data.shape) == 2:
                columns = [
                    ('c{}'.format(i), col)
                    for i, col in enumerate(zip(*data.tolist()))
                ]
            else:
                raise TypeError
        else:
            raise TypeError
        return cls(index=index, columns=columns)
54627
def to_math_type(arr):
    
    max_int = np.iinfo(arr.dtype).max
    return arr.astype(math_type) / max_int
823323
def _ConvertDataType(self, dataType):
      
      if dataType:
         vmodlName = dataType.name
         wsdlName = dataType.wsdlName
         version = dataType.version
         parent = dataType.base[0]
         props = self._Filter(self._ConvertDataPropertyType, dataType.property)
         doType = (vmodlName, wsdlName, parent, version, props)
      else:
         doType = None
      return doType
1243403
def _convert_strls(self, data):
        """"""
        convert_cols = [
            col for i, col in enumerate(data)
            if self.typlist[i] == 32768 or col in self._convert_strl]

        if convert_cols:
            ssw = StataStrLWriter(data, convert_cols)
            tab, new_data = ssw.generate_table()
            data = new_data
            self._strl_blob = ssw.generate_blob(tab)
        return data
1324044
function getType(obj) {
    let typeStr = typeof(obj);
    if (obj) {
        return Array.isArray(obj) ? 'array' : typeStr;
    } else {
        switch (typeStr) {
            case 'number':
                return obj === 0 ? 'number' : 'NaN';
            case 'object':
                return 'null';
            default:
                return typeStr;
        }
    }
}
707710
function num2str(type) {
  switch (Number(type)) {
    case types.BYTE:
      return 'byte';
    case types.CHAR:
      return 'char';
    case types.SHORT:
      return 'short';
    case types.INT:
      return 'int';
    case types.FLOAT:
      return 'float';
    case types.DOUBLE:
      return 'double';
      /* istanbul ignore next */
    default:
      return 'undefined';
  }
}
1123674
def _try_convert_data(self, name, data, use_dtypes=True,
                          convert_dates=True):
        

        # don't try to coerce, unless a force conversion
        if use_dtypes:
            if self.dtype is False:
                return data, False
            elif self.dtype is True:
                pass

            else:

                # dtype to force
                dtype = (self.dtype.get(name)
                         if isinstance(self.dtype, dict) else self.dtype)
                if dtype is not None:
                    try:
                        dtype = np.dtype(dtype)
                        return data.astype(dtype), True
                    except:
                        return data, False

        if convert_dates:
            new_data, result = self._try_convert_to_date(data)
            if result:
                return new_data, True

        result = False

        if data.dtype == 'object':

            # try float
            try:
                data = data.astype('float64')
                result = True
            except:
                pass

        if data.dtype.kind == 'f':

            if data.dtype != 'float64':

                # coerce floats to 64
                try:
                    data = data.astype('float64')
                    result = True
                except:
                    pass

        # do't coerce 0-len data
        if len(data) and (data.dtype == 'float' or data.dtype == 'object'):

            # coerce ints if we can
            try:
                new_data = data.astype('int64')
                if (new_data == data).all():
                    data = new_data
                    result = True
            except:
                pass

        # coerce ints to 64
        if data.dtype == 'int':

            # coerce floats to 64
            try:
                data = data.astype('int64')
                result = True
            except:
                pass

        return data, result
1130993
def _get_example_from_basic_type(type):
        
        if type == 'integer':
            return [42, 24]
        elif type == 'number':
            return [5.5, 5.5]
        elif type == 'string':
            return ['string', 'string2']
        elif type == 'datetime':
            return ['2015-08-28T09:02:57.481Z', '2015-08-28T09:02:57.481Z']
        elif type == 'boolean':
            return [False, True]
        elif type == 'null':
            return ['null', 'null']
16048
def check_type(param, datatype):
    
    if param is None:
        return param

    if getattr(datatype, 'clean', None) and callable(datatype.clean):
        try:
            return datatype.clean(param)
        except ValueError:
            raise BadArgumentError(param)

    elif isinstance(datatype, str):
        # You've given it something like `'bool'` as a string.
        # This is the legacy way of doing it.
        datatype = {
            'str': str,
            'bool': bool,
            'float': float,
            'date': datetime.date,
            'datetime': datetime.datetime,
            'timedelta': datetime.timedelta,
            'json': 'json',  # exception
            'int': int,
        }[datatype]

    if datatype is str and not isinstance(param, basestring):
        try:
            param = str(param)
        except ValueError:
            param = str()

    elif datatype is int and not isinstance(param, int):
        try:
            param = int(param)
        except ValueError:
            param = int()

    elif datatype is bool and not isinstance(param, bool):
        param = str(param).lower() in ("true", "t", "1", "y", "yes")

    elif (
        datatype is datetime.datetime and
        not isinstance(param, datetime.datetime)
    ):
        try:
            param = dtutil.string_to_datetime(param)
        except ValueError:
            param = None

    elif datatype is datetime.date and not isinstance(param, datetime.date):
        try:
            param = dtutil.string_to_datetime(param).date()
        except ValueError:
            param = None

    elif (
        datatype is datetime.timedelta and
        not isinstance(param, datetime.timedelta)
    ):
        try:
            param = dtutil.strHoursToTimeDelta(param)
        except ValueError:
            param = None

    elif datatype == "json" and isinstance(param, basestring):
        try:
            param = json.loads(param)
        except ValueError:
            param = None

    return param
275772
function typeToString(allowedType){
		if( allowedType === Number )	return 'Number'
		if( allowedType === String )	return 'String'
		if( allowedType === Object )	return 'Object'
		if( allowedType === undefined )	return 'undefined'
		return allowedType.toString()
	}
22876
function convertType (data) {
  switch (data.type) {
    case 'union':
      // If union of arrays
      if (Array.isArray(data.anyOf) && data.anyOf[0].type === 'array') {
        const items = data.anyOf.map(function (e) { return e.items })
        data.items = { anyOf: [] }
        data.items.anyOf = items
        data['type'] = 'array'
        delete data.anyOf
      } else {
        data['type'] = 'object'
      }
      break
    case 'nil':
      data['type'] = 'null'
      break
    case 'file':
      data = convertFileType(data)
      break
  }
  return data
}
772058
def fromType(datatype):
        
        if issubclass(datatype, GPBaseType):
            return GPBaseType._get_type_by_name("GPMultiValue:%s" % 
                                                datatype.__name__)
        else:
            return GPBaseType._get_type_by_name("GPMultiValue:%s" % 
                                                str(datatype))
138346
def _convert_types(self, a):
        
        # No conversion for scalar type
        if a.dtype != 'object':
            return a, None

        # We can't infer the type of an empty array, so just
        # assume strings
        if len(a) == 0:
            return a.astype('U1'), None

        # Compute a mask of missing values. Replace NaNs and Nones with
        # empty strings so that type inference has a chance.
        mask = pd.isnull(a)
        if mask.sum() > 0:
            a = a.copy()
            np.putmask(a, mask, '')
        else:
            mask = None

        if infer_dtype(a, skipna=False) == 'mixed':
            # assume its a string, otherwise raise an error
            try:
                a = np.array([s.encode('ascii') for s in a])
                a = a.astype('O')
            except:
                raise ValueError("Column of type 'mixed' cannot be converted to string")

        type_ = infer_dtype(a, skipna=False)
        if type_ in ['unicode', 'string']:
            max_len = max_len_string_array(a)
            return a.astype('U{:d}'.format(max_len)), mask
        else:
            raise ValueError('Cannot store arrays with {} dtype'.format(type_))
91936
def type(self):
        """"""
        if isinstance(self.value, numbers.Number):
            return "number"
        if isinstance(self.value, basestring):
            return "string"
        return "unknown"
1249962
def _convert_np_data(data, data_type, num_elems):   # @NoSelf
        '''
        
        '''
        if (data_type == 51 or data_type == 52):
            if (data == ''):
                return ('\x00'*num_elems).encode()
            else:
                return data.ljust(num_elems, '\x00').encode('utf-8')
        elif (data_type == 32):
            data_stream = data.real.tobytes()
            data_stream += data.imag.tobytes()
            return data_stream
        else:
            return data.tobytes()