def _get_level(value, levels, prefix=None):
 if ((value > 1) or (value < 0)):
  raise ValueError(('Encountered invalid normalized alpha diversity value %s. Normalized values must be between 0 and 1.' % value))
 check = [i for i in range(0, len(levels)) if (levels[i] == value)]
 if len(check):
  value_level = (check[0] + 2)
 else:
  value_level = (searchsorted(levels, value) + 1)
 if (prefix is not None):
  output = '{0}_{1}_of_{2}'.format(prefix, value_level, (len(levels) + 1))
 else:
  output = value_level
 return output

def _get_level ( value , levels , prefix = None ) : if ( ( value > 1 ) or ( value < 0 ) ) : raise ValueError ( ( 'Encountered invalid normalized alpha diversity value %s. Normalized values must be between 0 and 1.' % value ) ) check = [ i for i in range ( 0 , len ( levels ) ) if ( levels [ i ] == value ) ] if len ( check ) : value_level = ( check [ 0 ] + 2 ) else : value_level = ( searchsorted ( levels , value ) + 1 ) if ( prefix is not None ) : output = '{0}_{1}_of_{2}' . format ( prefix , value_level , ( len ( levels ) + 1 ) ) else : output = value_level return output
accommodate a value into the levels list; return a string or an integer input: value: normalized value to assign a level to .