code: def tempoAdjust4(self, tempoFactor):
      
  
      late_votes = (len(self.adtm.getNextBasalPredictedCells()) - len(self.apicalIntersect)) * -1
      early_votes = len(self.apicalIntersect)
      votes = late_votes + early_votes
      print('vote tally', votes)
  
      if votes > 0:
        newScale = 0.5
        print 'speed up'
  
      elif votes < 0:
        newScale = 2
        print 'slow down'
  
      elif votes == 0:
  
        if not self.scaleAdjustmentHistory:
          print 'pick randomly'
          if random.random() > 0.5:
            newScale = 0.5
            print 'random pick: speed up'
          else:
            newScale = 2
            print 'random pick: slow down'
  
        else:
          print 'tied: re-choose last choice'
          newScale = self.scaleAdjustmentHistory[-1]
  
  
      if self.disableVoting == 1:
  
        newScale = self.scaleAdjustmentHistory[-1]
  
      if len(self.scaleAdjustmentHistory) >1:
  
        if self.scaleAdjustmentHistory[-2] == self.scaleAdjustmentHistory[-1]:
  
          prevDirection = self.scaleAdjustmentHistory[-1]
          newScale = (prevDirection * prevDirection)**-2
          print('2 errors in a row; new scale is', tempoFactor * newScale)
  
          self.scaleAdjustmentHistory = []
          self.scaleAdjustmentHistory.append(prevDirection)
          tempoFactor = tempoFactor * newScale
          return tempoFactor
  
      self.scaleAdjustmentHistory.append(newScale)
      tempoFactor = tempoFactor * newScale
      print tempoFactor
      return tempoFactor
docs: Adjust tempo by aggregating active basal cell votes for pre vs. post
      -> if vote total = 0 (tied), use result of last vote
      -> if two wrong scale decisions in a row, use max/min tempo in opposite direction
  
      :param tempoFactor: scaling signal to MC clock from last sequence item
      :return: adjusted scaling signal