code: def trimSegments(self, minPermanence=None, minNumSyns=None):
      
  
      # Fill in defaults
      if minPermanence is None:
        minPermanence = self.connectedPerm
      if minNumSyns is None:
        minNumSyns = self.activationThreshold
  
      # Loop through all cells
      totalSegsRemoved, totalSynsRemoved = 0, 0
      for c,i in product(xrange(self.numberOfCols), xrange(self.cellsPerColumn)):
  
        (segsRemoved, synsRemoved) = self.trimSegmentsInCell(colIdx=c, cellIdx=i,
                  segList=self.cells[c][i], minPermanence=minPermanence,
                  minNumSyns=minNumSyns)
        totalSegsRemoved += segsRemoved
        totalSynsRemoved += synsRemoved
  
  
      return totalSegsRemoved, totalSynsRemoved
docs: This method deletes all synapses whose permanence is less than
      minPermanence and deletes any segments that have less than
      minNumSyns synapses remaining.
  
      Parameters:
      --------------------------------------------------------------
      minPermanence:      Any syn whose permamence is 0 or < minPermanence will
                          be deleted. If None is passed in, then
                          self.connectedPerm is used.
      minNumSyns:         Any segment with less than minNumSyns synapses remaining
                          in it will be deleted. If None is passed in, then
                          self.activationThreshold is used.
      retval:             (numSegsRemoved, numSynsRemoved)