Skip to content

Commit

Permalink
Merge pull request #273 from JanVanHaaren/fix/revert-242
Browse files Browse the repository at this point in the history
Revert changes to duel parsing logic in Opta deserializer
  • Loading branch information
koenvo authored Dec 29, 2023
2 parents b4f1644 + 206ab6d commit c3ed5e3
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions kloppy/infra/serializers/event/opta/deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
BallState,
DatasetFlag,
Orientation,
PassEvent,
ShotEvent,
TakeOnEvent,
GenericEvent,
PassResult,
ShotResult,
TakeOnResult,
Expand All @@ -32,12 +28,7 @@
Player,
Position,
InterceptionResult,
RecoveryEvent,
BallOutEvent,
FoulCommittedEvent,
FormationChangeEvent,
FormationType,
CardEvent,
CardType,
CardQualifier,
Qualifier,
Expand Down Expand Up @@ -66,7 +57,6 @@
EVENT_TYPE_TAKE_ON = 3
EVENT_TYPE_TACKLE = 7
EVENT_TYPE_AERIAL = 44
EVENT_TYPE_CHALLENGE = 45
EVENT_TYPE_50_50 = 67
EVENT_TYPE_INTERCEPTION = 8
EVENT_TYPE_CLEARANCE = 12
Expand Down Expand Up @@ -101,7 +91,6 @@
EVENT_TYPE_TACKLE,
EVENT_TYPE_AERIAL,
EVENT_TYPE_50_50,
EVENT_TYPE_CHALLENGE,
]

BALL_OWNING_EVENTS = (
Expand Down Expand Up @@ -414,15 +403,15 @@ def _parse_duel(
raw_qualifiers: Dict[int, str], type_id: int, outcome: int
) -> Dict:
qualifiers = _get_event_qualifiers(raw_qualifiers)
if type_id in (EVENT_TYPE_TACKLE, EVENT_TYPE_CHALLENGE):
if type_id == EVENT_TYPE_TACKLE:
qualifiers.extend([DuelQualifier(value=DuelType.GROUND)])
elif type_id == EVENT_TYPE_AERIAL:
qualifiers.extend(
[
DuelQualifier(value=DuelType.GROUND),
DuelQualifier(value=DuelType.TACKLE),
DuelQualifier(value=DuelType.LOOSE_BALL),
DuelQualifier(value=DuelType.AERIAL),
]
)
elif type_id == EVENT_TYPE_AERIAL:
qualifiers.append(DuelQualifier(value=DuelType.AERIAL))
elif type_id == EVENT_TYPE_50_50:
qualifiers.extend(
[
Expand Down

0 comments on commit c3ed5e3

Please sign in to comment.