validate the passed dtype
185909
def _validate_dtype(self, dtype):
        

        if dtype is not None:
            dtype = pandas_dtype(dtype)

            # a compound dtype
            if dtype.kind == 'V':
                raise NotImplementedError("compound dtypes are not implemented"
                                          " in the {0} constructor"
                                          .format(self.__class__.__name__))

        return dtype
387160
def _validate(cls, kind):
        """"""
        if kind not in cls._valid_kinds:
            mesg = "'kind' must be one of {}, {}, {}, or {}."
            raise ValueError(mesg.format(*cls._valid_kinds))
        else:
            return kind
844344
def _assert_is_type(name, value, value_type):
    """"""
    if not isinstance(value, value_type):
        if type(value_type) is tuple:
            types = ', '.join(t.__name__ for t in value_type)
            raise ValueError('{0} must be one of ({1})'.format(name, types))
        else:
            raise ValueError('{0} must be {1}'
                             .format(name, value_type.__name__))
1373024
def validate(data, schema, defined_keys=False):
    
    if isinstance(data, dict):
        validator = Validator(data, schema, defined_keys=defined_keys)
        validator.validate()
    else:
        raise TypeError('expected data to be of type dict, but got: %s' % type(data))
986549
def is_dtype_equal(self, other):
        

        try:
            return hash(self.dtype) == hash(other.dtype)
        except (AttributeError, TypeError):
            return False
1031563
def Validate(self, type_names):
    """"""
    errs = [n for n in self._RDFTypes(type_names) if not self._GetClass(n)]
    if errs:
      raise DefinitionError("Undefined RDF Types: %s" % ",".join(errs))
897312
def make_kind_check(python_types, numpy_kind):
    
    def check(value):
        if hasattr(value, 'dtype'):
            return value.dtype.kind == numpy_kind
        return isinstance(value, python_types)
    return check
1056241
def validate(self, value):
        """"""
        if self.type is not None:
            value = coerce(self.type, value)

        if self.min is not None and value < self.min:
            raise ValueError('%s=%s is less than %s' % (self.name, value,
                                                        self.min))
        if self.max is not None and value > self.max:
            raise ValueError('%s=%s is greater than %s' % (
                self.name, value, self.max))
        if self.allowed is not None and value not in self.allowed:
            raise ValueError('%s=%s is not one of the allowed values: %s' % (
                self.name, value, ','.join(map(str, self.allowed))))

        return value
1339615
def _can_use_numexpr(op, op_str, a, b, dtype_check):
    
    if op_str is not None:

        # required min elements (otherwise we are adding overhead)
        if np.prod(a.shape) > _MIN_ELEMENTS:

            # check for dtype compatibility
            dtypes = set()
            for o in [a, b]:
                if hasattr(o, 'get_dtype_counts'):
                    s = o.get_dtype_counts()
                    if len(s) > 1:
                        return False
                    dtypes |= set(s.index)
                elif isinstance(o, np.ndarray):
                    dtypes |= {o.dtype.name}

            # allowed are a superset
            if not len(dtypes) or _ALLOWED_DTYPES[dtype_check] >= dtypes:
                return True

    return False
848142
def validate_input(self):
        """"""
        if self.vert[1] <= self.vert[0]:
            raise ValueError(u'{} must be larger than {}'.format(self.vert[1], self.vert[0]))
184544
def _validate_series_dtype(self, series: pd.Series) -> pd.Series:
        """"""
        return series.apply(lambda i: isinstance(i, self.dtype))
234772
def validate(self, value):
        """"""
        value = self.pre_validate(value)
        if not self._typecheck(value):
            raise ValueError('%r failed type check' % value)
        return value
970165
def _validate(self, val):
        
        if self.allow_None and val is None:
            return

        if not isinstance(val, dt_types) and not (self.allow_None and val is None):
            raise ValueError("Date '%s' only takes datetime types."%self.name)

        if self.step is not None and not isinstance(self.step, dt_types):
            raise ValueError("Step parameter can only be None or a datetime type")

        self._checkBounds(val)
592260
def _validate(self):
        
        if self.data_format is FormatType.PYTHON:
            self.data = self.raw_data
        elif self.data_format is FormatType.JSON:
            self._validate_json()
        elif self.data_format is FormatType.YAML:
            self._validate_yaml()
1141727
def _ctypes_dtype(parameter):
    
    ctype = parameter.ctype
    if ctype is None:
        if parameter.kind is not None:
            return "{}({})".format(parameter.dtype, parameter.kind)
        else:
            return parameter.dtype
    else:
        return"{}({})".format(parameter.dtype, ctype)
1270830
def DtypeToType(self, dtype):
    """"""
    if dtype.char in np.typecodes['AllFloat']:
      return self.fs_proto.FLOAT
    elif (dtype.char in np.typecodes['AllInteger'] or dtype == np.bool or
          np.issubdtype(dtype, np.datetime64) or
          np.issubdtype(dtype, np.timedelta64)):
      return self.fs_proto.INT
    else:
      return self.fs_proto.STRING
812255
def ensure_dtype(core, dtype, dtype_):
    """"""
    core = core.copy()
    if dtype is None:
        dtype = dtype_

    if dtype_ == dtype:
        return core, dtype

    for key, val in {
            int: chaospy.poly.typing.asint,
            float: chaospy.poly.typing.asfloat,
            np.float32: chaospy.poly.typing.asfloat,
            np.float64: chaospy.poly.typing.asfloat,
    }.items():

        if dtype == key:
            converter = val
            break
    else:
        raise ValueError("dtype not recognised (%s)" % str(dtype))

    for key, val in core.items():
        core[key] = converter(val)
    return core, dtype