Is PA terminal
        :param ball_tally: Ball telly
        :param strike_tally: Strike telly
        :param pitch_res: pitching result(Retrosheet format)
        :param event_cd: Event code
        :return: FLG(T or F)
167901
def is_pa_terminal(cls, ball_tally, strike_tally, pitch_res, event_cd):
        
        if RetroSheet.is_pa_terminal(ball_tally, strike_tally, pitch_res, event_cd):
            return MlbamConst.FLG_TRUE
        return MlbamConst.FLG_FALSE
92955
def _get_batting_order_starting_flg(cls, batter):
        
        bo = batter.get('bo', None)
        if not bo or len(bo) != 3:
            return False, False
        batting_order = bo[:1]
        starting = True if bo[1:3] == '00' else False
        return batting_order, starting
760839
def adjustPitchmarkers(self):
        ''''''
        pitchdiff = self.dist10deg*(self.pitch/10.0)
        rollRotate = mpl.transforms.Affine2D().rotate_deg_around(0.0,-pitchdiff,self.roll)+self.axes.transData
        j=0
        for i in [-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9]:
            width = self.calcPitchMarkerWidth(i)
            self.pitchPatches[j].set_xy((-width/2.0,self.dist10deg*i-(self.thick/2.0)-pitchdiff))
            self.pitchPatches[j].set_transform(rollRotate)
            j+=1
        # Adjust Text Size and rotation
        i=0
        for j in [-9,-6,-3,3,6,9]:
                self.pitchLabelsLeft[i].set_y(j*self.dist10deg-pitchdiff)
                self.pitchLabelsRight[i].set_y(j*self.dist10deg-pitchdiff)
                self.pitchLabelsLeft[i].set_size(self.fontSize)
                self.pitchLabelsRight[i].set_size(self.fontSize)
                self.pitchLabelsLeft[i].set_rotation(self.roll)
                self.pitchLabelsRight[i].set_rotation(self.roll)
                self.pitchLabelsLeft[i].set_transform(rollRotate)
                self.pitchLabelsRight[i].set_transform(rollRotate)
                i += 1
1064533
def get_league_scores(self, league, time, show_upcoming, use_12_hour_format):

        
        time_frame = 'n' if show_upcoming else 'p'
        if league:
            try:
                league_id = self.league_ids[league]
                req = self._get('competitions/{id}/matches?timeFrame={time_frame}{time}'.format(
                     id=league_id, time_frame=time_frame, time=str(time)))
                fixtures_results = req.json()
                # no fixtures in the past week. display a help message and return
                if len(fixtures_results["matches"]) == 0:
                    click.secho("No {league} matches in the past week.".format(league=league),
                                fg="red", bold=True)
                    return
                self.writer.league_scores(fixtures_results,
                                          time, show_upcoming,
                                          use_12_hour_format)
            except APIErrorException:
                click.secho("No data for the given league.", fg="red", bold=True)
        else:
            # When no league specified. Print all available in time frame.
            try:
                req = self._get('matches?timeFrame={time_frame}{time}'.format(
                     time_frame=time_frame, time=str(time)))
                fixtures_results = req.json()
                self.writer.league_scores(fixtures_results,
                                          time,
                                          show_upcoming,
                                          use_12_hour_format)
            except APIErrorException:
                click.secho("No data available.", fg="red", bold=True)
1058037
def cmd_rally_move(self, args):
        ''''''
        if len(args) < 1:
            print("Usage: rally move RALLYNUM")
            return
        if not self.have_list:
            print("Please list rally points first")
            return

        idx = int(args[0])
        if idx <= 0 or idx > self.rallyloader.rally_count():
            print("Invalid rally point number %u" % idx)
            return

        rpoint = self.rallyloader.rally_point(idx-1)

        try:
            latlon = self.module('map').click_position
        except Exception:
            print("No map available")
            return
        if latlon is None:
            print("No map click position available")
            return

        oldpos = (rpoint.lat*1e-7, rpoint.lng*1e-7)
        self.rallyloader.move(idx, latlon[0], latlon[1])
        self.send_rally_point(idx-1)
        p = self.fetch_rally_point(idx-1)
        if p.lat != int(latlon[0]*1e7) or p.lng != int(latlon[1]*1e7):
            print("Rally move failed")
            return
        self.rallyloader.reindex()
        print("Moved rally point from %s to %s at %fm" % (str(oldpos), str(latlon), rpoint.alt))
1079972
def ball_count(cls, ball_tally, strike_tally, pitch_res):
        
        b, s = ball_tally, strike_tally
        if pitch_res == "B":
            if ball_tally < 4:
                b += 1
        elif pitch_res == "S" or pitch_res == "C" or pitch_res == "X":
            if strike_tally < 3:
                s += 1
        elif pitch_res == "F":
            if strike_tally < 2:
                s += 1
        return b, s
1135091
function onGetPlayers(pdata) {
    $(PLAYERS).empty();
    // display all players
    for (var p in pdata) {
        if (!pdata.hasOwnProperty(p)) {
            continue;
        }
        var turn = pdata[p].has_turn ? "has_turn" : "";
        $(PLAYERS).append("<dt class='" + turn + "'>" + esc(p) + "</dt>" +
                          "<dd>" + pdata[p].points + "</dd>");
    }

    var my_game = $.cookie("game");
    var my_player = $.cookie("player");
    if (my_player) {
        if (pdata[my_player] === undefined) {
            // I've got a player name, but we need to add it to the game
            $.post("/games/" + enc(my_game) + "/players", {name: my_player},
                   function() {getPlayers();});
        } else if (HAVETURN !== pdata[my_player].has_turn) {
            HAVETURN = pdata[my_player].has_turn;
            if (HAVETURN) {
                countdownTimer();
            } else {
                clearTimeout(COUNTDOWNTID);
            }
            drawTurnInfo(pdata);
        }
    }
}
1114953
public static int pitch_fr3(          /* output: integer part of pitch period        */
	 float exc[],int excs,           /* input : excitation buffer                   */
	 float xn[],int xns,            /* input : target vector                       */
	 float h[], int hs,            /* input : impulse response of filters.        */
	 int l_subfr,           /* input : Length of frame to compute pitch    */
	 int t0_min,            /* input : minimum value in the searched range */
	 int t0_max,            /* input : maximum value in the searched range */
	 int i_subfr,           /* input : indicator for first subframe        */
	 IntegerPointer pit_frac          /* output: chosen fraction                     */
	)
	{
	  int    i, frac;
	  int    lag, t_min, t_max;
	  float  max;
	  float  corr_int;
	  float  corr_v[] = new float[10+2*LD8KConstants.L_INTER4];  /* size: 2*L_INTER4+t0_max-t0_min+1 */
	  int  corr;

	  /* Find interval to compute normalized correlation */

	  t_min = t0_min - LD8KConstants.L_INTER4;
	  t_max = t0_max + LD8KConstants.L_INTER4;

	  corr = -t_min;    /* corr[t_min:t_max] */

	  /* Compute normalized correlation between target and filtered excitation */

	  norm_corr(exc, excs, xn, xns, h, hs, l_subfr, t_min, t_max, corr_v, corr);

	  /* find integer pitch */

	  max = corr_v[corr+t0_min];
	  lag  = t0_min;

	  for(i= t0_min+1; i<=t0_max; i++)
	  {
	    if( corr_v[corr+i] >= max)
	    {
	      max = corr_v[corr+i];
	      lag = i;
	    }
	  }

	  /* If first subframe and lag > 84 do not search fractionnal pitch */

	  if( (i_subfr == 0) && (lag > 84) )
	  {
	    pit_frac.value = 0;
	    return(lag);
	  }

	  /* test the fractions around lag and choose the one which maximizes
	     the interpolated normalized correlation */

	  max  = interpol_3(corr_v, corr+lag, -2);
	  frac = -2;

	  for (i = -1; i <= 2; i++)
	  {
	    corr_int = interpol_3(corr_v, corr+lag, i);
	    if(corr_int > max)
	    {
	      max = corr_int;
	      frac = i;
	    }
	  }

	  /* limit the fraction value in the interval [-1,0,1] */

	  if (frac == -2)
	  {
	    frac = 1;
	    lag -= 1;
	  }
	  if (frac == 2)
	  {
	    frac = -1;
	    lag += 1;
	  }

	  pit_frac.value = frac;

	  return lag;
	}
1111772
def _download(self, timestamp):
        
        games, atbats, pitches = [], [], []
        rosters, coaches, umpires = [], [], []
        boxscores, actions = [], []
        timestamp_params = {
            'year': str(timestamp.year),
            'month': str(timestamp.month).zfill(2),
            'day': str(timestamp.day).zfill(2)
        }

        logging.info('->- Game data download start({year}/{month}/{day})'.format(**timestamp_params))

        base_url = self.DELIMITER.join([self.url, self.PAGE_URL_GAME_DAY.format(**timestamp_params)])
        html = MlbamUtil.find_xml(base_url, self.parser)

        href = self.PAGE_URL_GAME_PREFIX.format(**timestamp_params)
        for gid in html.find_all('a', href=re.compile(href)):
            gid_path = gid.get_text().strip()
            gid_url = self.DELIMITER.join([base_url, gid_path])
            # Read XML & create dataset
            try:
                game = Game.read_xml(gid_url, self.parser, timestamp, MlbAm._get_game_number(gid_path))
                players = Players.read_xml(gid_url, self.parser, game)
                innings = Inning.read_xml(gid_url, self.parser, game, players)
                boxscore = BoxScore.read_xml(gid_url, self.parser, game, players)
            except MlbAmHttpNotFound as e:
                logging.warning(e.msg)
                continue

            # append a dataset
            games.append(game.row())
            rosters.extend([roseter.row() for roseter in players.rosters.values()])
            coaches.extend([coach.row() for coach in players.coaches.values()])
            umpires.extend([umpire.row() for umpire in players.umpires.values()])
            atbats.extend(innings.atbats)
            pitches.extend(innings.pitches)
            actions.extend(innings.actions)
            boxscores.append(boxscore.row())

        # writing csv
        day = "".join([timestamp_params['year'], timestamp_params['month'], timestamp_params['day']])
        for params in (
                {'datasets': games, 'filename': Game.DOWNLOAD_FILE_NAME},
                {'datasets': rosters, 'filename': Players.Player.DOWNLOAD_FILE_NAME},
                {'datasets': coaches, 'filename': Players.Coach.DOWNLOAD_FILE_NAME},
                {'datasets': umpires, 'filename': Players.Umpire.DOWNLOAD_FILE_NAME},
                {'datasets': atbats, 'filename': AtBat.DOWNLOAD_FILE_NAME},
                {'datasets': pitches, 'filename': Pitch.DOWNLOAD_FILE_NAME},
                {'datasets': boxscores, 'filename': BoxScore.DOWNLOAD_FILE_NAME},
                {'datasets': actions, 'filename': InningAction.DOWNLOAD_FILE_NAME},
        ):
            self._write_csv(params['datasets'], params['filename'].format(day=day, extension=self.extension))
        time.sleep(2)

        logging.info('-<- Game data download end({year}/{month}/{day})'.format(**timestamp_params))
122493
def get_pitchers(home_or_away)
      if self.gid
        bs = get_boxscore
        if home_or_away == 'away'
          bs.pitchers[0]
        else
          bs.pitchers[1]
        end
      else
        puts "No data for input specified"
      end
    end
453776
def game_events(game_id, innings_endpoint=False):
    """"""
    # get data from data module
    if not innings_endpoint:
        data = mlbgame.data.get_game_events(game_id)
        endpoint = 'game_events'
    else:
        data = mlbgame.data.get_innings(game_id)
        endpoint = 'innings'
    # parse XML
    parsed = etree.parse(data)
    root = parsed.getroot()
    # empty output file
    output = {}
    # loop through innings
    innings = root.findall('inning')
    for x in innings:
        output[x.attrib['num']] = {
            'top': __inning_info(x, 'top', endpoint),
            'bottom': __inning_info(x, 'bottom', endpoint)
        }
    return output
211955
def cmd_up(self, args):
        ''''''
        if len(args) == 0:
            adjust = 5.0
        else:
            adjust = float(args[0])
        old_trim = self.get_mav_param('TRIM_PITCH_CD', None)
        if old_trim is None:
            print("Existing trim value unknown!")
            return
        new_trim = int(old_trim + (adjust*100))
        if math.fabs(new_trim - old_trim) > 1000:
            print("Adjustment by %d too large (from %d to %d)" % (adjust*100, old_trim, new_trim))
            return
        print("Adjusting TRIM_PITCH_CD from %d to %d" % (old_trim, new_trim))
        self.param_set('TRIM_PITCH_CD', new_trim)
122582
def pointTo(agent_host, ob, target_pitch, target_yaw, threshold):
    ''''''
    pitch = ob.get(u'Pitch', 0)
    yaw = ob.get(u'Yaw', 0)
    delta_yaw = angvel(target_yaw, yaw, 50.0)
    delta_pitch = angvel(target_pitch, pitch, 50.0)
    agent_host.sendCommand("turn " + str(delta_yaw))    
    agent_host.sendCommand("pitch " + str(delta_pitch))
    if abs(pitch-target_pitch) + abs(yaw-target_yaw) < threshold:
        agent_host.sendCommand("turn 0")
        agent_host.sendCommand("pitch 0")
        return True
    return False
1150275
def format_ga_hit(self, field_name, error_message):
        
        tracking_id = self.get_ga_tracking_id()
        if not tracking_id:
            warnings.warn('Google Analytics tracking ID is not set')
            return None
        query_dict = self.get_ga_query_dict()
        query_dict['tid'] = tracking_id
        query_dict['cid'] = self.get_ga_client_id()
        query_dict['ec'] = self.get_ga_event_category()
        query_dict['ea'] = field_name
        query_dict['el'] = error_message
        return query_dict.urlencode()
1116078
def _get_pitch(self, soup, pa):
        
        pitches = []
        ball_tally, strike_tally = 0, 0
        for pitch in soup.find_all('pitch'):
            # pitching result
            pitch = Pitch.row(pitch, pa, pitches, ball_tally, strike_tally)
            pitches.append(pitch)
            # ball count
            ball_tally, strike_tally = RetroSheet.ball_count(ball_tally, strike_tally, pitch['pitch_res'])
        return pitches
630100
async def enable_analog_reporting(self, command):
        
        pin = int(command[0])
        await self.core.enable_analog_reporting(pin)
198565
def _inning_events(self, soup, inning_number, inning_id, hit_location):
        
        # at bat(batter box data) & pitching data
        out_ct = 0
        for ab in soup.find_all('atbat'):
            # plate appearance data(pa)
            at_bat = AtBat.pa(ab, self.game, self.players.rosters, inning_number, inning_id, out_ct, hit_location)
            # pitching data
            pitching_stats = self._get_pitch(ab, at_bat)
            # at bat(pa result)
            pa_result = AtBat.result(ab, at_bat, pitching_stats)
            at_bat.update(pa_result)
            self.atbats.append(at_bat)
            self.pitches.extend(pitching_stats)
            # out count
            out_ct = at_bat['event_outs_ct']