def _maybe_convert_scalar(values):
 if is_scalar(values):
  (dtype, values) = _infer_dtype_from_scalar(values)
  try:
   values = dtype(values)
  except TypeError:
   pass
 return values

def _maybe_convert_scalar ( values ) : if is_scalar ( values ) : ( dtype , values ) = _infer_dtype_from_scalar ( values ) try : values = dtype ( values ) except TypeError : pass return values
convert a python scalar to the appropriate numpy dtype if possible this avoids numpy directly converting according to platform preferences .