Sets the pitchers of record (win, lose, save) from data in the master_scoreboard.xml file
518952
def set_pitchers(element)
      element.elements.each("winning_pitcher") do |wp|
        @winning_pitcher = Player.new
        @winning_pitcher.init_pitcher_from_scoreboard(wp)
      end
      element.elements.each("losing_pitcher") do |lp|
        @losing_pitcher = Player.new
        @losing_pitcher.init_pitcher_from_scoreboard(lp)
      end
      element.elements.each("save_pitcher") do |sp|
        @save_pitcher = Player.new
        @save_pitcher.first = sp.attributes['first']
        @save_pitcher.last = sp.attributes['last']
        @save_pitcher.saves = sp.attributes['saves']
      end
    end
286998
def scoreboard(
        game_date=Date.today,
        day_offset=0,
        league_id=NbaStats::Constants::LEAGUE_ID_NBA
    )
      NbaStats::Resources::Scoreboard.new(
          get(SCOREBOARD_PATH, {
              :LeagueID => league_id,
              :GameDate => game_date.strftime('%m-%d-%Y'),
              :DayOffset => day_offset
          })
      )
    end
737080
private void setRecords(byte[][] data) {
        if (data == null || data.length==0) {
            this.records = EMPTY_DATA;
            return;
        }

        this.records = new byte[data.length][];
        for (int i = 0; i < data.length; i++) {
            if (data[i] != null) {
                this.records[i] = data[i];
            } else {
                this.records[i] = EMPTY_BYTES;
            }
        }
    }
252854
def set_innings(element)
        element.elements.each("linescore/inning") { |element|
           @away_innings << element.attributes['away']
           @home_innings << element.attributes['home']
        }
      end
468151
def set_pitchers
      @pitchers, away_pitchers, home_pitchers = [], [], []
      count = 1
      @xml_doc.elements.each("boxscore/pitching[@team_flag='away']/pitcher") { |element| 
        pitcher = PitchingAppearance.new
        pitcher.init(@gid, element, count)
        count += 1
        away_pitchers.push pitcher
      }   
      count = 1
      @xml_doc.elements.each("boxscore/pitching[@team_flag='home']/pitcher") { |element| 
        pitcher = PitchingAppearance.new
        pitcher.init(@gid, element, count)
        count += 1
        home_pitchers.push pitcher
      }   
      @pitchers << away_pitchers
      @pitchers << home_pitchers
    end
171664
function (progress, adv) {
  if (progress) {
    var id = progress[0]
      , pos = progress[1]
      , insertM = this.findMatch(id);

    if (!insertM) {
      throw new Error('tournament corrupt: ' + id + ' not found!');
    }

    insertM.p[pos] = adv;
    if (insertM.p[(pos + 1) % 2] === WO) {
      insertM.m = (pos) ? [0, 1] : [1, 0]; // set WO map scores
      return insertM.id; // this id was won by adv on WO, inform
    }
  }
}
72532
def score_file(filename):
  """"""
  # Prepare model.
  hparams = create_hparams()
  encoders = registry.problem(FLAGS.problem).feature_encoders(FLAGS.data_dir)
  has_inputs = "inputs" in encoders

  # Prepare features for feeding into the model.
  if has_inputs:
    inputs_ph = tf.placeholder(dtype=tf.int32)  # Just length dimension.
    batch_inputs = tf.reshape(inputs_ph, [1, -1, 1, 1])  # Make it 4D.
  targets_ph = tf.placeholder(dtype=tf.int32)  # Just length dimension.
  batch_targets = tf.reshape(targets_ph, [1, -1, 1, 1])  # Make it 4D.
  if has_inputs:
    features = {"inputs": batch_inputs, "targets": batch_targets}
  else:
    features = {"targets": batch_targets}

  # Prepare the model and the graph when model runs on features.
  model = registry.model(FLAGS.model)(hparams, tf.estimator.ModeKeys.EVAL)
  _, losses = model(features)
  saver = tf.train.Saver()

  with tf.Session() as sess:
    # Load weights from checkpoint.
    if FLAGS.checkpoint_path is None:
      ckpts = tf.train.get_checkpoint_state(FLAGS.output_dir)
      ckpt = ckpts.model_checkpoint_path
    else:
      ckpt = FLAGS.checkpoint_path
    saver.restore(sess, ckpt)
    # Run on each line.
    with tf.gfile.Open(filename) as f:
      lines = f.readlines()
    results = []
    for line in lines:
      tab_split = line.split("\t")
      if len(tab_split) > 2:
        raise ValueError("Each line must have at most one tab separator.")
      if len(tab_split) == 1:
        targets = tab_split[0].strip()
      else:
        targets = tab_split[1].strip()
        inputs = tab_split[0].strip()
      # Run encoders and append EOS symbol.
      targets_numpy = encoders["targets"].encode(
          targets) + [text_encoder.EOS_ID]
      if has_inputs:
        inputs_numpy = encoders["inputs"].encode(inputs) + [text_encoder.EOS_ID]
      # Prepare the feed.
      if has_inputs:
        feed = {inputs_ph: inputs_numpy, targets_ph: targets_numpy}
      else:
        feed = {targets_ph: targets_numpy}
      # Get the score.
      np_loss = sess.run(losses["training"], feed)
      results.append(np_loss)
  return results
530431
def team_stats(game_id):
    """"""
    # get data
    data = mlbgame.stats.team_stats(game_id)
    return mlbgame.stats.Stats(data, game_id, False)
804427
def update_member_data_in(self, leaderboard_name, member, member_data):
        '''
        
        '''
        self.redis_connection.hset(
            self._member_data_key(leaderboard_name),
            member,
            member_data)
863253
def pitching_stats_range(start_dt=None, end_dt=None):
    
    # ensure valid date strings, perform necessary processing for query
    start_dt, end_dt = sanitize_input(start_dt, end_dt)
    if datetime.datetime.strptime(start_dt, "%Y-%m-%d").year < 2008:
        raise ValueError("Year must be 2008 or later")
    if datetime.datetime.strptime(end_dt, "%Y-%m-%d").year < 2008:
        raise ValueError("Year must be 2008 or later")
    # retrieve html from baseball reference
    soup = get_soup(start_dt, end_dt)
    table = get_table(soup)
    table = table.dropna(how='all') # drop if all columns are NA
    #fix some strange formatting for percentage columns
    table = table.replace('---%', np.nan)
    #make sure these are all numeric
    for column in ['Age', '#days', 'G', 'GS', 'W', 'L', 'SV', 'IP', 'H',
                    'R', 'ER', 'BB', 'SO', 'HR', 'HBP', 'ERA', 'AB', '2B',
                    '3B', 'IBB', 'GDP', 'SF', 'SB', 'CS', 'PO', 'BF', 'Pit',
                    'WHIP', 'BAbip', 'SO9', 'SO/W']:
        table[column] = pd.to_numeric(table[column])
    #convert str(xx%) values to float(0.XX) decimal values
    for column in ['Str', 'StL', 'StS', 'GB/FB', 'LD', 'PU']:
        table[column] = table[column].replace('%','',regex=True).astype('float')/100

    table = table.drop('',1)
    return table
881028
def live_scores(self, live_scores):
        """"""
        headers = ['League', 'Home Team Name', 'Home Team Goals',
                   'Away Team Goals', 'Away Team Name']
        result = [headers]
        result.extend([game['league'], game['homeTeamName'],
                       game['goalsHomeTeam'], game['goalsAwayTeam'],
                       game['awayTeamName']] for game in live_scores['games'])
        self.generate_output(result)
666588
private void addReplicaStatsOf(RecordStore recordStore, LocalMapOnDemandCalculatedStats onDemandStats) {
        if (!hasRecords(recordStore)) {
            return;
        }

        long backupEntryCount = 0;
        long backupEntryMemoryCost = 0;

        int totalBackupCount = recordStore.getMapContainer().getTotalBackupCount();
        for (int replicaNumber = 1; replicaNumber <= totalBackupCount; replicaNumber++) {
            int partitionId = recordStore.getPartitionId();
            Address replicaAddress = getReplicaAddress(partitionId, replicaNumber, totalBackupCount);
            if (!isReplicaAvailable(replicaAddress, totalBackupCount)) {
                printWarning(partitionId, replicaNumber);
                continue;
            }
            if (isReplicaOnThisNode(replicaAddress)) {
                backupEntryMemoryCost += recordStore.getOwnedEntryCost();
                backupEntryCount += recordStore.size();
            }
        }

        if (NATIVE != recordStore.getMapContainer().getMapConfig().getInMemoryFormat()) {
            onDemandStats.incrementHeapCost(backupEntryMemoryCost);
        }
        onDemandStats.incrementBackupEntryMemoryCost(backupEntryMemoryCost);
        onDemandStats.incrementBackupEntryCount(backupEntryCount);
        onDemandStats.setBackupCount(recordStore.getMapContainer().getMapConfig().getTotalBackupCount());
    }
427394
def _generate_object(cls, soup, game, players):
        

        def get_batter(soup, team_flag):
            batting = soup.find('batting', attrs={'team_flag': team_flag})
            if batting:
                return batting.find_all('batter')
            return []

        def get_pitcher(soup, team_flag):
            pitching = soup.find('pitching', attrs={'team_flag': team_flag})
            if pitching:
                return pitching.find_all('pitcher')
            return []

        box_score = BoxScore(game, players)

        box_score.retro_game_id = game.retro_game_id
        box_score.home_team_id = game.home_team_id
        box_score.away_team_id = game.away_team_id
        box_score.home_batting = [box_score._get_batter(b) for b in get_batter(soup, 'home')]
        box_score.away_batting = [box_score._get_batter(b) for b in get_batter(soup, 'away')]
        box_score.home_pitching = [box_score._get_pitcher(p) for p in get_pitcher(soup, 'home')]
        box_score.away_pitching = [box_score._get_pitcher(p) for p in get_pitcher(soup, 'away')]

        return box_score
614861
def _set_player(self):
        
        players = []
        for name, p in self._mpris_players.items():
            # we set the priority here as we need to establish the player name
            # which might not be immediately available.
            if "_priority" not in p:
                if self.player_priority:
                    try:
                        priority = self.player_priority.index(p["name"])
                    except ValueError:
                        try:
                            priority = self.player_priority.index("*")
                        except ValueError:
                            priority = None
                else:
                    priority = 0
                if priority is not None:
                    p["_priority"] = priority
            if p.get("_priority") is not None:
                players.append((p["_state_priority"], p["_priority"], p["index"], name))
        if players:
            top_player = self._mpris_players.get(sorted(players)[0][3])
        else:
            top_player = {}

        self._player = top_player.get("_dbus_player")
        self._player_details = top_player

        self.py3.update()
528467
def update_picks(self, games=None, points=None):
        '''
        
        '''
        if games:
            game_dict = {g.id: g for g in self.gameset.games.filter(id__in=games)}
            game_picks = {pick.game.id: pick for pick in self.gamepicks.filter(game__id__in=games)}
            for key, winner in games.items():
                game = game_dict[key]
                if not game.has_started:
                    pick = game_picks[key]
                    pick.winner_id = winner
                    pick.save()

        if points is not None:
            self.points = points
            self.save()

        if games or points:
            self.updated_signal.send(sender=self.__class__, pickset=self, auto_pick=False)
764669
public void set(Rec record) throws DBException
    {
        if ((this.getRecord().getEditMode() != Constants.EDIT_CURRENT)
            && ((this.getRecord().getEditMode() != Constants.EDIT_IN_PROGRESS)))
                throw new DBException(Constants.INVALID_RECORD);
        m_record = (FieldList)record;
        this.fieldsToData(record);
        this.doSet(record);
        this.setDataSource(null);
        this.getRecord().setEditMode(Constants.EDIT_NONE);
    }
209725
def get_standings(date):
    """"""
    try:
        return urlopen(STANDINGS_URL.format(date.year,
                                            date.strftime('%Y/%m/%d')))
    except HTTPError:
        ValueError('Could not find the standings file. '
                   'mlb.com does not provide the file that '
                   'mlbgame needs to perform this operation.')