Skip to content

Commit

Permalink
made sure functionality is correct, if player doesn't exist, create p…
Browse files Browse the repository at this point in the history
…layer
  • Loading branch information
Joris Bekkers committed Jul 10, 2024
1 parent 0c2a5ea commit c8cd1e3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions kloppy/infra/serializers/tracking/tracab/tracab_dat.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ def _frame_from_line(cls, teams, period, line, frame_rate):
)

player = team.get_player_by_jersey_number(jersey_no)
if player:
players_data[player] = PlayerData(
coordinates=Point(float(x), float(y)), speed=float(speed)
)
else:
if not player:
player = Player(
player_id=f"{team.ground}_{jersey_no}",
team=team,
jersey_no=int(jersey_no),
)
team.players.append(player)

players_data[player] = PlayerData(
coordinates=Point(float(x), float(y)), speed=float(speed)
)

(
ball_x,
ball_y,
Expand Down Expand Up @@ -182,7 +182,6 @@ def deserialize(self, inputs: TRACABInputs) -> TrackingDataset:
)
)


if meta_data.get("HomeTeam") and meta_data.get("AwayTeam"):
home_team = self.create_team(
meta_data["HomeTeam"], Ground.HOME, start_frame_id
Expand All @@ -191,8 +190,12 @@ def deserialize(self, inputs: TRACABInputs) -> TrackingDataset:
meta_data["AwayTeam"], Ground.AWAY, start_frame_id
)
else:
home_team = Team(team_id="home", name="home", ground=Ground.HOME)
away_team = Team(team_id="away", name="away", ground=Ground.AWAY)
home_team = Team(
team_id="home", name="home", ground=Ground.HOME
)
away_team = Team(
team_id="away", name="away", ground=Ground.AWAY
)
teams = [home_team, away_team]

with performance_logging("Loading data", logger=logger):
Expand Down

0 comments on commit c8cd1e3

Please sign in to comment.