code: 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
docs: Ensure dtype is correct.