Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DuelEvent #204

Merged
merged 9 commits into from
Jul 14, 2023
Merged

Add DuelEvent #204

merged 9 commits into from
Jul 14, 2023

Conversation

MKlaasman
Copy link
Contributor

PR related to issue described in #135

Added DuelEvent for:
• StatsBomb, Opta & WyScout (v2 & v3); including tests
• Added DuelTypes: AERIAL, GROUND, LOOSE_BALL & SLIDING_TACKLE
• Added .get_qualifier_values() to get a list of qualifiers instead of the first value.

@probberechts can you take a look, whether this suffices?

1.	Remained with Pieter’s initial proposal of only adding: AERIAL, GROUND, LOOSE_BALL & SLIDING_TACKLE
2.	StatsBomb: Checked qualifiers with “name” instead of id, since ids are not consistent in StatsBomb open data. As per StatsBomb helpdesk.
3.	Added a method: .get_qualifier_values() . Which returns a list of Qualifiers instead of .get_qualifier_value(), that returns the first Qualifier.
4.	Also Added NEUTRAL as outcome, since this is provided in wyscout_v2
@MKlaasman MKlaasman changed the title Feature/add duel events Add DuelEvent Jul 5, 2023
@koenvo koenvo added this to the Socceraction requirements milestone Jul 6, 2023
if qualifiers:
return qualifiers

return None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect this function to always return List type.

So always return qualifiers

result = DuelResult.LOST

return dict(
result=result,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to result=DuelResult.WON if outcome else DuelResult.LOST

else:
result = DuelResult.LOST

return {"result": result, "qualifiers": qualifiers}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do similar as above using DuelResult.WON if outcome_name in DUEL_WON_NAMES else DuelResult.LOST

**duel_event_kwargs,
**generic_event_kwargs,
)
new_events.append(duel_event)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this happen before the shot/clearance/miscontrol/pass event or after (using .append)?

@@ -386,9 +418,9 @@ def deserialize(self, inputs: WyscoutInputs) -> EventDataset:
**recovery_event_args, **generic_event_args
)
elif raw_event["eventId"] == wyscout_events.DUEL.EVENT:
takeon_event_args = _parse_takeon(raw_event)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice!

@koenvo
Copy link
Contributor

koenvo commented Jul 6, 2023

Thanks for this pull request!

Some minor comments and can you make sure to merge master in as there seem to be some conflicts.

# Conflicts:
#	kloppy/domain/models/event.py
#	kloppy/domain/services/event_factory.py
#	kloppy/infra/serializers/event/opta/deserializer.py
#	kloppy/infra/serializers/event/statsbomb/deserializer.py
#	kloppy/infra/serializers/event/wyscout/deserializer_v2.py
#	kloppy/infra/serializers/event/wyscout/deserializer_v3.py
#	kloppy/tests/files/wyscout_events_v3.json
#	kloppy/tests/test_wyscout.py
@MKlaasman
Copy link
Contributor Author

@koenvo should be good to merge.

Copy link
Contributor

@probberechts probberechts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

requirements.txt Outdated
pytz~=2023.3
python-dateutil~=2.8.2
setuptools~=67.8.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the intention behind having a setuptools entry in requirements.txt? I think you can’t install Setuptools from the requirements.txt file anyway because you need to have Setuptools installed in order to install anything (with Pip) in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MKlaasman can you update this one?

requirements.txt Outdated
pre-commit
kloppy~=3.11.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kloppy shouldn't be a requirement of Kloppy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MKlaasman can you update this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how I introduced these...

Deleted all requirements not present in current master, namely:
kloppy~=3.11.0
pytz~=2023.3
python-dateutil~=2.8.2
setuptools~=67.8.0

Please double check whether this is correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct now. Thanks!

# Conflicts:
#	kloppy/infra/serializers/event/opta/deserializer.py
#	kloppy/tests/test_opta.py
#	kloppy/tests/test_wyscout.py
@koenvo koenvo merged commit ec18671 into PySport:master Jul 14, 2023
@DriesDeprest DriesDeprest deleted the feature/add_duel_events branch August 11, 2023 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants