def _copytobuffer(x):
 isfloat = False
 islist = False
 istuple = False
 if hasattr(x, 'shape'):
  if (x.shape == ()):
   return _copytobuffer_return_scalar(x)
  else:
   try:
    x.dtype.char
    inx = x.copy(order='C').astype('d')
    return (inx, False, False, False)
   except:
    try:
     x.typecode()
     inx = x.astype('d')
     return (inx, False, False, False)
    except:
     raise TypeError('input must be an array, list, tuple or scalar')
 elif hasattr(x, 'typecode'):
  inx = array('d', x)
 elif (type(x) == list):
  inx = array('d', x)
  islist = True
 elif (type(x) == tuple):
  inx = array('d', x)
  istuple = True
 else:
  return _copytobuffer_return_scalar(x)
 return (inx, isfloat, islist, istuple)

def _copytobuffer ( x ) : isfloat = False islist = False istuple = False if hasattr ( x , 'shape' ) : if ( x . shape == ( ) ) : return _copytobuffer_return_scalar ( x ) else : try : x . dtype . char inx = x . copy ( order = 'C' ) . astype ( 'd' ) return ( inx , False , False , False ) except : try : x . typecode ( ) inx = x . astype ( 'd' ) return ( inx , False , False , False ) except : raise TypeError ( 'input must be an array, list, tuple or scalar' ) elif hasattr ( x , 'typecode' ) : inx = array ( 'd' , x ) elif ( type ( x ) == list ) : inx = array ( 'd' , x ) islist = True elif ( type ( x ) == tuple ) : inx = array ( 'd' , x ) istuple = True else : return _copytobuffer_return_scalar ( x ) return ( inx , isfloat , islist , istuple )
return a copy of x as an object that supports the python buffer api .