Skip to content

Commit

Permalink
fix(Stats Perform): Ignore 19/"Player on" events as they are already …
Browse files Browse the repository at this point in the history
…incorporated in SubstitutionEvent (#361)
  • Loading branch information
DriesDeprest authored Dec 17, 2024
1 parent dff0204 commit e359a99
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions kloppy/infra/serializers/event/statsperform/deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ def deserialize(self, inputs: StatsPerformInputs) -> EventDataset:
f"Set end of period {period.id} to {raw_event.timestamp}"
)
period.end_timestamp = raw_event.timestamp
elif raw_event.type_id == EVENT_TYPE_PLAYER_ON:
continue
else:
if not period.start_timestamp:
# not started yet
Expand Down
4 changes: 2 additions & 2 deletions kloppy/tests/issues/issue_60/test_issue_60.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_deleted_event_opta(self):
assert deleted_event_id not in df["event_id"].to_list()

# OPTA F24 file: Pass -> Deleted Event -> Tackle
assert event_dataset.events[16].event_name == "pass"
assert event_dataset.events[15].event_name == "pass"
assert (
event_dataset.events[17].event_name == "duel"
event_dataset.events[16].event_name == "duel"
) # Deleted Event is filter out
2 changes: 1 addition & 1 deletion kloppy/tests/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ def read_to_stream(self, url: str, output: BinaryIO):
# Asserts borrowed from `test_opta.py`
assert dataset.metadata.provider == Provider.OPTA
assert dataset.dataset_type == DatasetType.EVENT
assert len(dataset.events) == 40
assert len(dataset.events) == 39
2 changes: 1 addition & 1 deletion kloppy/tests/test_statsperform.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_deserialize_all(self, event_dataset: EventDataset):
pitch_length=None,
pitch_width=None,
)
assert len(event_dataset.records) == 1652
assert len(event_dataset.records) == 1643

substitution_events = event_dataset.find_all("substitution")
assert len(substitution_events) == 9
Expand Down

0 comments on commit e359a99

Please sign in to comment.