code: def select(self, crit):
          
          import types
  
          # handle lists, strings, and ints
          if not isinstance(crit, types.FunctionType):
              # set("foo") -> {"f", "o"}; wrap in list to prevent:
              if isinstance(crit, string_types):
                  critlist = set([crit])
              else:
                  try:
                      critlist = set(crit)
                  except TypeError:
                      # typically means crit is not an iterable type; for instance, crit is an int
                      critlist = set([crit])
              crit = lambda x: x in critlist
  
          # if only one index, return it directly or throw an error
          index = self.index
          if size(index) == 1:
              if crit(index[0]):
                  return self
              else:
                  raise Exception('No indices found matching criterion')
  
          # determine new index and check the result
          newindex = [i for i in index if crit(i)]
          if len(newindex) == 0:
              raise Exception('No indices found matching criterion')
          if array(newindex == index).all():
              return self
  
          # use fast logical indexing to get the new values
          subinds = where([crit(i) for i in index])
          new = self.map(lambda x: x[subinds], index=newindex)
  
          # if singleton, need to check whether it's an array or a scalar/int
          # if array, recompute a new set of indices
          if len(newindex) == 1:
              new = new.map(lambda x: x[0], index=newindex)
              val = new.first()
              if size(val) == 1:
                  newindex = [newindex[0]]
              else:
                  newindex = arange(0, size(val))
  
          new._index = newindex
  
          return new
docs: Select subset of values that match a given index criterion.
  
          Parameters
          ----------
          crit : function, list, str, int
              Criterion function to map to indices, specific index value,
              or list of indices.