def validate_metadata(map_fp, gradient_variable):
 metadata = parse_mapping_file(map_fp)
 if (not (gradient_variable in metadata[1])):
  raise Exception((('Header %s not found in metadata headers: ' % gradient_variable) + ', '.join(metadata[1])))
 column_ix = metadata[1].index(gradient_variable)
 gradient = zip(*metadata[0])[column_ix]
 for i in xrange(len(gradient)):
  try:
   float(gradient[i])
  except ValueError:
   if (gradient[i] != 'NA'):
    raise Exception((('Non-numeric value %s found in metadata gradient column: ' % gradient[i]) + ', '.join(gradient)))

def validate_metadata ( map_fp , gradient_variable ) : metadata = parse_mapping_file ( map_fp ) if ( not ( gradient_variable in metadata [ 1 ] ) ) : raise Exception ( ( ( 'Header %s not found in metadata headers: ' % gradient_variable ) + ', ' . join ( metadata [ 1 ] ) ) ) column_ix = metadata [ 1 ] . index ( gradient_variable ) gradient = zip ( * metadata [ 0 ] ) [ column_ix ] for i in xrange ( len ( gradient ) ) : try : float ( gradient [ i ] ) except ValueError : if ( gradient [ i ] != 'NA' ) : raise Exception ( ( ( 'Non-numeric value %s found in metadata gradient column: ' % gradient [ i ] ) + ', ' . join ( gradient ) ) )
ensures that gradient variable is indeed present and real-valued if not .