def val2array(value, withNone=True, withScalar=True, length=2):
 if (value is None):
  if withNone:
   return None
  else:
   raise ValueError('Invalid parameter. None is not accepted as value.')
 value = numpy.array(value, float)
 if (numpy.product(value.shape) == 1):
  if withScalar:
   return numpy.repeat(value, length)
  else:
   msg = 'Invalid parameter. Single numbers are not accepted. Should be tuple/list/array of length %s'
   raise ValueError((msg % str(length)))
 elif (value.shape[(-1)] == length):
  return numpy.array(value, float)
 else:
  msg = 'Invalid parameter. Should be length %s but got length %s.'
  raise ValueError((msg % (str(length), str(len(value)))))

def val2array ( value , withNone = True , withScalar = True , length = 2 ) : if ( value is None ) : if withNone : return None else : raise ValueError ( 'Invalid parameter. None is not accepted as value.' ) value = numpy . array ( value , float ) if ( numpy . product ( value . shape ) == 1 ) : if withScalar : return numpy . repeat ( value , length ) else : msg = 'Invalid parameter. Single numbers are not accepted. Should be tuple/list/array of length %s' raise ValueError ( ( msg % str ( length ) ) ) elif ( value . shape [ ( - 1 ) ] == length ) : return numpy . array ( value , float ) else : msg = 'Invalid parameter. Should be length %s but got length %s.' raise ValueError ( ( msg % ( str ( length ) , str ( len ( value ) ) ) ) )
helper function: converts different input to a numpy array .