Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified tests/files/plot/test-1.mp4
Binary file not shown.
Binary file modified tests/files/plot/test-no-extension.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/files/plot/test-png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions tests/test_kloppy_polars.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,21 @@ def custom_edge_feature(**kwargs):
verbose=False,
)

# def test_skillcorner_warning(
# self, kloppy_dataset: TrackingDataset
# ) -> KloppyPolarsDataset:
# with pytest.warns(UserWarning):
# dataset = KloppyPolarsDataset(
# kloppy_dataset=kloppy_dataset,
# ball_carrier_threshold=25.0,
# max_player_speed=12.0,
# max_player_acceleration=12.0,
# max_ball_speed=13.5,
# max_ball_acceleration=100,
# )
# dataset.add_dummy_labels(by=["game_id", "frame_id"], random_seed=42)
# dataset.add_graph_ids(by=["game_id", "frame_id"])

def test_incorrect_custom_features_no_decorator(
self, kloppy_polars_dataset: KloppyPolarsDataset
) -> SoccerGraphConverterPolars:
Expand Down
19 changes: 12 additions & 7 deletions unravel/soccer/dataset/kloppy_polars.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import polars as pl

import warnings


DEFAULT_PLAYER_SMOOTHING_PARAMS = {"window_length": 7, "polyorder": 1}
DEFAULT_BALL_SMOOTHING_PARAMS = {"window_length": 3, "polyorder": 1}
Expand Down Expand Up @@ -688,13 +690,16 @@ def load(
df = df.drop(["dx", "dy", "dz", "dt", "dvx", "dvy", "dvz"])
df = df.filter(~(pl.col(Column.X).is_null() & pl.col(Column.Y).is_null()))

if (
df[Column.BALL_OWNING_TEAM_ID].is_null().all()
and self.ball_carrier_threshold is None
):
raise ValueError(
f"This dataset requires us to infer the {Column.BALL_OWNING_TEAM_ID}, please specifiy a ball_carrier_threshold (float) to do so."
)
if df[Column.BALL_OWNING_TEAM_ID].is_null().all():
if self.ball_carrier_threshold is None:
raise ValueError(
f"This dataset requires us to infer the {Column.BALL_OWNING_TEAM_ID}, please specifiy a ball_carrier_threshold (float) to do so."
)
else:
warnings.warn(
"This dataset does not come with 'ball owning team' information. As a result we infer this using distance to ball using the 'ball_carrier_threshold'. Please note this might cause unexpected results.",
UserWarning,
)

df = self.__infer_ball_carrier(df)

Expand Down
5 changes: 5 additions & 0 deletions unravel/soccer/graphs/graph_converter_pl.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ def _apply_padding(self) -> pl.DataFrame:
for col in user_defined_columns
]
)

padding_df = padding_df.with_columns(
[pl.col(col).cast(df.schema[col]).alias(col) for col in group_by_columns]
)

padding_df = padding_df.join(
(
df.unique(group_by_columns).select(
Expand Down