Make sure that x, y have consistent types and set dtype.
182974
def _set_types(self):
        """"""
        # If we given something that is not an int or a float we raise
        # a RuntimeError as we do not want to have to guess if the given
        # input should be interpreted as an int or a float, for example the
        # interpretation of the string "1" vs the interpretation of the string
        # "1.0".
        for c in (self.x, self.y):
            if not ( isinstance(c, int) or isinstance(c, float) ):
                raise(RuntimeError('x, y coords should be int or float'))

        if isinstance(self.x, int) and isinstance(self.y, int):
            self._dtype = "int"
        else:
            # At least one value is a float so promote both to float.
            self.x = float(self.x)
            self.y = float(self.y)
            self._dtype = "float"
986549
def is_dtype_equal(self, other):
        

        try:
            return hash(self.dtype) == hash(other.dtype)
        except (AttributeError, TypeError):
            return False
546320
def _coerce_dtype(self, other_dtype):
        
        if self._dtype is None:
            new_dtype = np.dtype(other_dtype)
        else:
            new_dtype = np.find_common_type([self._dtype, np.dtype(other_dtype)], [])
        if new_dtype != self.dtype:
            self.set_dtype(new_dtype)
1043960
def _check_data(self, X):
        '''
        
        '''

        if len(X) > 1:
            sval = np.unique(X[0][:, 1])
            if np.all([np.all(np.unique(X[i][:, 1]) == sval) for i in range(1, len(X))]):
                pass
            else:
                raise ValueError("Unique identifier var_types not consistent between time series")
1167847
def make_type_consistent(s1, s2):
    """"""
    if isinstance(s1, str) and isinstance(s2, str):
        return s1, s2

    elif isinstance(s1, unicode) and isinstance(s2, unicode):
        return s1, s2

    else:
        return unicode(s1), unicode(s2)
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]))
124066
def as_shared_dtype(scalars_or_arrays):
    """"""
    arrays = [asarray(x) for x in scalars_or_arrays]
    # Pass arrays directly instead of dtypes to result_type so scalars
    # get handled properly.
    # Note that result_type() safely gets the dtype from dask arrays without
    # evaluating them.
    out_type = dtypes.result_type(*arrays)
    return [x.astype(out_type, copy=False) for x in arrays]
596840
def _coerce_to_type(x):
    
    dtype = None

    if is_datetime64tz_dtype(x):
        dtype = x.dtype
    elif is_datetime64_dtype(x):
        x = to_datetime(x)
        dtype = np.dtype('datetime64[ns]')
    elif is_timedelta64_dtype(x):
        x = to_timedelta(x)
        dtype = np.dtype('timedelta64[ns]')

    if dtype is not None:
        # GH 19768: force NaT to NaN during integer conversion
        x = np.where(x.notna(), x.view(np.int64), np.nan)

    return x, dtype
223532
def set_type(self, value):
        """"""
        if value not in self.types_available:
            log = "Sources field 'type' should be in one of %s" % (
                self.types_available
            )
            raise MalFormattedSource(log)
        self._type = value
222793
private void setType(Type type) {
    setSamplesPerSecond(type.getSamplesPerSecond());
    setFramesPerSecond(type.getFramesPerSecond());
    setUseSamples(type.usesSamples());
  }
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
1103724
def _combine(self, x, y):
    """"""
    if x is None or y is None:
      return x or y
    if x != y:
      raise ValueError('Incompatible set of constraints provided.')
    return x
744517
def fit(self, X, y):
        """"""

        self._data = X
        self._classes = np.unique(y)
        self._labels = y
        self._is_fitted = True
955734
def _valid_other_type(x, types):
    
    return all(any(isinstance(el, t) for t in types) for el in np.ravel(x))
853888
protected function setDefaultDataTypes()
    {
        foreach ($this->_params as $key => $value) {
            switch (gettype($value)) {
                case "boolean":
                    $this->_types[$key] = 'boolean';
                    break;
                case "integer":
                    $this->_types[$key] = 'integer';
                    break;
                case "double":
                    $this->_types[$key] = 'float';
                    break;
                case "string":
                    $this->_types[$key] = 'string';
                    break;
                case "array":
                    $this->_types[$key] = 'array';
                    break;
                default:
                    $this->_types[$key] = null;
                    break;
            }
        }
    }
133633
def validate(self, instance, value):
        """"""
        if not isinstance(value, (tuple, list, np.ndarray)):
            self.error(instance, value)
        if self.coerce:
            value = self.wrapper(value)
        valid_class = (
            self.wrapper if isinstance(self.wrapper, type) else np.ndarray
        )
        if not isinstance(value, valid_class):
            self.error(instance, value)
        allowed_kinds = ''.join(TYPE_MAPPINGS[typ] for typ in self.dtype)
        if value.dtype.kind not in allowed_kinds:
            self.error(instance, value, extra='Invalid dtype.')
        if self.shape is None:
            return value
        for shape in self.shape:
            if len(shape) != value.ndim:
                continue
            for i, shp in enumerate(shape):
                if shp not in ('*', value.shape[i]):
                    break
            else:
                return value
        self.error(instance, value, extra='Invalid shape.')
243778
def _to_corrected_pandas_type(dt):
    
    import numpy as np
    if type(dt) == ByteType:
        return np.int8
    elif type(dt) == ShortType:
        return np.int16
    elif type(dt) == IntegerType:
        return np.int32
    elif type(dt) == FloatType:
        return np.float32
    else:
        return None