Skip to content

Commit

Permalink
fix for unrecognized player
Browse files Browse the repository at this point in the history
  • Loading branch information
DriesDeprest committed Oct 29, 2024
1 parent ef2c398 commit d39f9ff
Show file tree
Hide file tree
Showing 3 changed files with 3,126 additions and 0 deletions.
1 change: 1 addition & 0 deletions kloppy/infra/serializers/event/wyscout/deserializer_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ def deserialize(self, inputs: WyscoutInputs) -> EventDataset:
"team": team,
"player": players[team_id][player_id]
if player_id != INVALID_PLAYER
and player_id in players[team_id]
else None,
"ball_owning_team": ball_owning_team,
"ball_state": None,
Expand Down
39 changes: 39 additions & 0 deletions kloppy/tests/prs/pr_358/test_pr_358.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from datetime import datetime, timedelta, timezone
from pathlib import Path

import pytest
from kloppy.domain import (
BodyPart,
BodyPartQualifier,
Point,
EventDataset,
SetPieceType,
SetPieceQualifier,
DatasetType,
DuelQualifier,
DuelType,
EventType,
GoalkeeperQualifier,
GoalkeeperActionType,
CardQualifier,
CardType,
Orientation,
PassResult,
FormationType,
Time,
PassType,
PassQualifier,
)

from kloppy import wyscout


def test_ignore_unknown_player(base_dir):
dataset = wyscout.load(
event_data=base_dir / "prs" / "pr_358" / "wyscout_events_v3.json",
coordinates="wyscout",
)

assert len(dataset.events) == 2

assert dataset.events[1].player is None
Loading

0 comments on commit d39f9ff

Please sign in to comment.