def _scalar_to_format(value):
 for type_ in (int, float, complex):
  try:
   value = type_(value)
   break
  except ValueError:
   continue
 numpy_dtype_str = np.min_scalar_type(value).str
 numpy_dtype_str = numpy_dtype_str[1:]
 try:
  fits_format = NUMPY2FITS[numpy_dtype_str]
  return FITSUPCONVERTERS.get(fits_format, fits_format)
 except KeyError:
  return ('A' + str(len(value)))

def _scalar_to_format ( value ) : for type_ in ( int , float , complex ) : try : value = type_ ( value ) break except ValueError : continue numpy_dtype_str = np . min_scalar_type ( value ) . str numpy_dtype_str = numpy_dtype_str [ 1 : ] try : fits_format = NUMPY2FITS [ numpy_dtype_str ] return FITSUPCONVERTERS . get ( fits_format , fits_format ) except KeyError : return ( 'A' + str ( len ( value ) ) )
given a scalar value or string .