diff --git a/kloppy/domain/models/common.py b/kloppy/domain/models/common.py index 09e18cbb..88e60e06 100644 --- a/kloppy/domain/models/common.py +++ b/kloppy/domain/models/common.py @@ -290,8 +290,8 @@ class Orientation(Enum): ACTION_EXECUTING_TEAM = "action-executing-team" # changes during half-time - HOME_TEAM = "home-team" - AWAY_TEAM = "away-team" + HOME_AWAY = "home-away" + AWAY_HOME = "away-home" # won't change during match FIXED_HOME_AWAY = "fixed-home-away" @@ -305,7 +305,7 @@ def get_attacking_direction(self, period: Period) -> AttackingDirection: return AttackingDirection.HOME_AWAY if self == Orientation.FIXED_AWAY_HOME: return AttackingDirection.AWAY_HOME - if self == Orientation.HOME_TEAM: + if self == Orientation.HOME_AWAY: dirmap = { 1: AttackingDirection.HOME_AWAY, 2: AttackingDirection.AWAY_HOME, @@ -313,7 +313,7 @@ def get_attacking_direction(self, period: Period) -> AttackingDirection: 4: AttackingDirection.AWAY_HOME, } return dirmap.get(period.id, period.attacking_direction) - if self == Orientation.AWAY_TEAM: + if self == Orientation.AWAY_HOME: dirmap = { 1: AttackingDirection.AWAY_HOME, 2: AttackingDirection.HOME_AWAY, @@ -335,7 +335,7 @@ def get_orientation_factor( return 1 if self == Orientation.FIXED_AWAY_HOME: return -1 - if self == Orientation.HOME_TEAM: + if self == Orientation.HOME_AWAY: if period.id == 1 or period.id == 3: return 1 if period.id == 2 or period.id == 4: @@ -343,7 +343,7 @@ def get_orientation_factor( raise OrientationError( f"AttackingDirection not defined for period with id {period.id}" ) - if self == Orientation.AWAY_TEAM: + if self == Orientation.AWAY_HOME: if period.id == 1 or period.id == 3: return -1 if period.id == 2 or period.id == 4: diff --git a/kloppy/tests/test_helpers.py b/kloppy/tests/test_helpers.py index cadfe6ac..f0e398af 100644 --- a/kloppy/tests/test_helpers.py +++ b/kloppy/tests/test_helpers.py @@ -58,7 +58,7 @@ def _get_tracking_dataset(self): pitch_dimensions=PitchDimensions( x_dim=Dimension(0, 100), y_dim=Dimension(-50, 50) ), - orientation=Orientation.HOME_TEAM, + orientation=Orientation.HOME_AWAY, frame_rate=25, periods=periods, teams=teams, @@ -108,7 +108,7 @@ def test_transform(self): # orientation change AND dimension scale transformed_dataset = tracking_data.transform( - to_orientation="AWAY_TEAM", + to_orientation="AWAY_HOME", to_pitch_dimensions=[[0, 1], [0, 1]], ) @@ -119,7 +119,7 @@ def test_transform(self): x=1, y=0, z=1 ) assert ( - transformed_dataset.metadata.orientation == Orientation.AWAY_TEAM + transformed_dataset.metadata.orientation == Orientation.AWAY_HOME ) assert transformed_dataset.metadata.coordinate_system is None assert ( @@ -153,11 +153,11 @@ def test_transform_to_pitch_dimensions(self): def test_transform_to_orientation(self): # Create a dataset with the KLOPPY pitch dimensions - # and HOME_TEAM orientation + # and HOME_AWAY orientation original = self._get_tracking_dataset().transform( to_pitch_dimensions=[[0, 1], [0, 1]], ) - assert original.metadata.orientation == Orientation.HOME_TEAM + assert original.metadata.orientation == Orientation.HOME_AWAY assert original.frames[0].ball_coordinates == Point3D(x=1, y=0, z=0) assert original.frames[1].ball_coordinates == Point3D(x=0, y=1, z=1) # the frames should have the correct attacking direction @@ -179,12 +179,12 @@ def test_transform_to_orientation(self): == AttackingDirection.AWAY_HOME ) - # Transform to AWAY_TEAM orientation + # Transform to AWAY_HOME orientation transform1 = original.transform( - to_orientation=Orientation.AWAY_TEAM, + to_orientation=Orientation.AWAY_HOME, to_pitch_dimensions=[[0, 1], [0, 1]], ) - assert transform1.metadata.orientation == Orientation.AWAY_TEAM + assert transform1.metadata.orientation == Orientation.AWAY_HOME # all coordinates should be flipped assert transform1.frames[0].ball_coordinates == Point3D(x=0, y=1, z=0) assert transform1.frames[1].ball_coordinates == Point3D(x=1, y=0, z=1) @@ -265,9 +265,9 @@ def test_transform_to_orientation(self): for period in transform4.metadata.periods: assert period.attacking_direction == AttackingDirection.NOT_SET - # Transform back to the original HOME_TEAM orientation + # Transform back to the original HOME_AWAY orientation transform5 = transform4.transform( - to_orientation=Orientation.HOME_TEAM, + to_orientation=Orientation.HOME_AWAY, to_pitch_dimensions=[[0, 1], [0, 1]], ) # we should be back at the original