allows us to override ratings in cases where they make the robot look stupid
515488
def imperative_move
      # if we can win *this turn*, then take it because
      # it rates winning next turn the same as winning in 3 turns
      game.available_moves.each do |move|
        new_game = game.pristine_mark move
        return move if new_game.over? && new_game.winner == player_number
      end
      
      # if we can block the opponent from winning *this turn*, then take it, because
      # it rates losing this turn the same as losing in 3 turns
      if moves_by_rating.all? { |move, rating, game| rating == -1 }
        Game.winning_states do |position1, position2, position3|
          a, b, c = board[position1-1, 1].to_i, board[position2-1, 1].to_i, board[position3-1, 1].to_i
          if a + b + c == opponent_number * 2
            return a.zero? ? position1 : b.zero? ? position2 : position3
          end
        end
      end
    end
368741
def toggle_inhibit(self):
        """"""
        if self.inhibit:
            self._controller.set_inhibit(False)
            self.inhibit = False
        else:
            self._controller.set_inhibit(True)
            self.inhibit = True
1315712
def __update_rating(uid, rating):
        '''
        
        '''
        entry = TabPost.update(
            rating=rating
        ).where(TabPost.uid == uid)
        entry.execute()
1365456
def override_if_not_in_args(flag, argument, args):
  """"""
  if flag not in args:
    args.extend([flag, argument])
1106808
function applyToCardState(prev, ts, rating) {
  if (prev.lastReviewed != null && prev.lastReviewed > ts) {
    var p = prev.lastReviewed.toISOString();
    var t = ts.toISOString();
    throw new Error('cannot apply review before current lastReviewed: ' + p + ' > ' + t);
  }

  if (prev.mode === 'learning') {
    return applyToLearningCardState(prev, ts, rating);
  } else if (prev.mode === 'reviewing') {
    return applyToReviewingCardState(prev, ts, rating);
  } else if (prev.mode === 'lapsed') {
    return applyToLapsedCardState(prev, ts, rating);
  }
  throw new Error('invalid mode: ' + prev.mode);
}
1190779
def update_obj
      mean, sd = rating.to_glicko_rating
      @obj.rating = mean
      @obj.rating_deviation = sd
      @obj.volatility = volatility
    end
1230733
protected void revalidateLayout() {
        for (MaterialIcon icon : iconList) {
            icon.removeFromParent();
        }
        iconList.clear();

        // same mouse-out handler for all icons
        MouseOutHandler outHandler = event -> {
            if (!isEnabled() || !isEditable()) {
                return;
            }
            revalidateSelection(currentRating);
        };

        for (int i = 0; i < maxRating; i++) {
            final int rating = i + 1;
            MaterialIcon icon = new MaterialIcon(unselectedRatingIcon);
            registerHandler(icon.addClickHandler(event -> {
                if (!isEnabled() || !isEditable()) {
                    return;
                }
                setValue(rating, true);
            }));

            registerHandler(icon.addMouseOverHandler(event -> {
                if (!isEnabled() || !isEditable()) {
                    return;
                }
                revalidateSelection(rating);
            }));

            registerHandler(icon.addMouseOutHandler(outHandler));
            add(icon);
            iconList.add(icon);
        }
        revalidateSelection(currentRating);
    }
198549
function addonsManager_undo(aSpec) {
    var spec = aSpec || { };
    spec.link = "undo";

    var link = this.getAddonLink(spec);
    this._controller.click(link);
  }
885891
def override_spec(cls, **kwargs):
        """"""
        cls._default_spec.set(**kwargs)
        cls.spec.set(**kwargs)
1319031
public void prohibitModifications() {
    lock.writeLock().lock();
    try {
      throwException = false;
      veto = true;
    } finally {
      lock.writeLock().unlock();
    }
  }
558695
private void pruneOutliers(BundleAdjustment<SceneStructureMetric> bundleAdjustment) {
		// see if it's configured to not prune
		if( pruneFraction == 1.0 )
			return;
		PruneStructureFromSceneMetric pruner = new PruneStructureFromSceneMetric(structure,observations);
		pruner.pruneObservationsByErrorRank(pruneFraction);
		pruner.pruneViews(10);
		pruner.prunePoints(1);
		bundleAdjustment.setParameters(structure,observations);
		bundleAdjustment.optimize(structure);

		if( verbose != null ) {
			verbose.println("\nCamera");
			for (int i = 0; i < structure.cameras.length; i++) {
				verbose.println(structure.cameras[i].getModel().toString());
			}
			verbose.println("\n\nworldToView");
			for (int i = 0; i < structure.views.length; i++) {
				verbose.println(structure.views[i].worldToView.toString());
			}
			verbose.println("Fit Score: " + bundleAdjustment.getFitScore());
		}
	}
882151
def get_override_winner(self, obj):
        """"""
        if obj.election.division.level.name == DivisionLevel.DISTRICT:
            division = obj.election.division.parent
        else:
            division = obj.election.division

        vote = obj.votes.filter(division=division).first()
        return vote.winning if vote else False
151440
def delete(self, *args, **kwargs):
        """"""
        # XXX: circular import
        from fields import RatingField

        qs = self.distinct().values_list('content_type', 'object_id').order_by('content_type')
    
        to_update = []
        for content_type, objects in itertools.groupby(qs, key=lambda x: x[0]):
            model_class = ContentType.objects.get(pk=content_type).model_class()
            if model_class:
                to_update.extend(list(model_class.objects.filter(pk__in=list(objects)[0])))
        
        retval = super(VoteQuerySet, self).delete(*args, **kwargs)
        
        # TODO: this could be improved
        for obj in to_update:
            for field in getattr(obj, '_djangoratings', []):
                getattr(obj, field.name)._update(commit=False)
            obj.save()
        
        return retval
1165709
protected function AllowRateReviews()
    {
        $bAllowRateReviews = $this->AllowReadReview();
        if ($bAllowRateReviews) {
            $oModuleConfiguration = $this->GetModuleConfiguration();
            if (!$oModuleConfiguration->fieldAllowRateReview) {
                $bAllowRateReviews = false;
            }
        }

        return $bAllowRateReviews;
    }
377714
def rating(self, value):
        """"""
        self._rating = value
        self._thumb  = self._link_to_img()
491462
def set_override_chan(self, channel, value):
        ''''''
        self.override[channel] = value
        self.override_counter = 10
        self.send_rc_override()
505588
def add(other_rating, score)
      g, e = other_rating.gravity_expected_score(rating.mean)
      @v_pre += g**2 * e * (1 - e)
      @delta_pre += g * (score - e)
    end