Regular Best Bets
502993
def search_best_bets_index
      response = @http.get(query_url)
      parsed_response = JSON.parse(response.body)
      if parsed_response['response']['numFound'].to_s == '0'
        return nil
      else
        resp = parsed_response['response']['docs'][0]
        result = OpenStruct.new
        result.title = title(resp)
        result.link = link(resp)
        result.id = id(resp)
        result.description = description(resp)
        result.best_bets_type = 'best-bets-regular'

        @response = result
      end
    end
1042496
function defaultSlots(slots) {
      return Array.isArray(slots)
        ? slots.slice()
        : googletag.pubads().getSlots().slice();
    }
757976
def choose(self):
        """"""
        if not self.choosed:
            self.choosed = True
            self.pos = self.pos + Sep(5, 0)
347611
def stake(confidence, value, tournament):
    """"""
    click.echo(napi.stake(confidence, value, tournament))
745870
def _rule_option(self):
        

        name = self._get_token(self.RE_NAME)
        value = self._rule_value()
        self._expect_token(';')
        return [name, value]
1245204
def guess(cls, *strings, **kwargs):
        '''
        
        '''
        license = None
        for string in strings:
            license = cls.guess_one(string)
            if license:
                break
        return license or kwargs.get('default')
315974
def mkCuttingStock(s):
    """"""
    w,q = [],[]   # list of different widths (sizes) of items, their quantities
    for item in sorted(s):
        if w == [] or item != w[-1]:
            w.append(item)
            q.append(1)
        else:
            q[-1] += 1
    return w,q
146421
def getOffbids(self, g):
        
        if not g.is_load:
            offbids = [x for x in self.offers if x.generator == g]
        else:
            offbids = [x for x in self.bids if x.vLoad == g]

        return offbids
1170350
def best_item_from_list(item,options,fuzzy=90,fname_match=True,fuzzy_fragment=None,guess=False):
    ''''''
    match = best_match_from_list(item,options,fuzzy,fname_match,fuzzy_fragment,guess)
    if match:
        return match[0]
    return None
1119114
def regret(self):
        '''
        
        '''

        return (sum(self.pulls)*np.max(np.nan_to_num(self.wins/self.pulls)) -
                sum(self.wins)) / sum(self.pulls)
380771
def update(self, bandit, payout):
        '''
        
        '''

        self.choices.append(bandit)
        self.pulls[bandit] += 1
        self.wins[bandit] += payout
        self.bandits.payouts[bandit] += payout
431451
def winning_abbr(self):
        
        if self.winner == HOME:
            return utils._parse_abbreviation(self._home_name)
        return utils._parse_abbreviation(self._away_name)
117838
def best_match(self, target, choices):
        

        all = self.all_matches

        try:
            best = next(all(target, choices, group=False))
            return best
        except StopIteration:
            pass
772837
def bandit_sticky_choose(exp)
      name = "bandit_#{exp}".intern
      # choose url param with preference
      value = params[name].nil? ? cookies.signed[name] : params[name]
      # sticky choice may outlast a given alternative
      alternative = if Bandit.get_experiment(exp).alternatives.include?(value)
                      value
                    else
                      Bandit.get_experiment(exp).choose(value)
                    end
      # re-set cookie
      cookies.permanent.signed[name] = alternative
    end
1011759
def softmax(self, params):
        '''
        
        '''

        default_tau = 0.1

        if params and type(params) == dict:
            tau = params.get('tau')
            try:
                float(tau)
            except ValueError:
                'slots: softmax: Setting tau to default'
                tau = default_tau
        else:
            tau = default_tau

        # Handle cold start. Not all bandits tested yet.
        if True in (self.pulls < 3):
            return np.random.choice(range(len(self.pulls)))
        else:
            payouts = self.wins / (self.pulls + 0.1)
            norm = sum(np.exp(payouts/tau))

        ps = np.exp(payouts/tau)/norm

        # Randomly choose index based on CMF
        cmf = [sum(ps[:i+1]) for i in range(len(ps))]

        rand = np.random.rand()

        found = False
        found_i = None
        i = 0
        while not found:
            if rand < cmf[i]:
                found_i = i
                found = True
            else:
                i += 1

        return found_i
985371
def get_applicable_values(self):
        """"""
        return [v for v in self._values if v.is_active and not v.is_all_results]
1261193
def _run(self, strategy, parameters=None):
        '''
        
        '''

        choice = self.run_strategy(strategy, parameters)
        self.choices.append(choice)
        payout = self.bandits.pull(choice)
        if payout is None:
            print('Trials exhausted. No more values for bandit', choice)
            return None
        else:
            self.wins[choice] += payout
        self.pulls[choice] += 1