Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
koenvo committed Jul 22, 2023
1 parent 5fff037 commit 2034364
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions kloppy/infra/serializers/event/sportec/deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class SportecMetadata(NamedTuple):
fps: int


def _sportec_metadata_from_xml_elm(match_root) -> SportecMetadata:
def sportec_metadata_from_xml_elm(match_root) -> SportecMetadata:
"""
Load metadata from Sportec XML element. This part is shared between event- and tracking data.
In the future this might move to a common.sportec package that provides functionality for both
Expand Down Expand Up @@ -369,7 +369,7 @@ def deserialize(self, inputs: SportecEvenDataInputs) -> EventDataset:
event_root = objectify.fromstring(inputs.event_data.read())

with performance_logging("parse data", logger=logger):
sportec_metadata = _sportec_metadata_from_xml_elm(match_root)
sportec_metadata = sportec_metadata_from_xml_elm(match_root)
teams = home_team, away_team = sportec_metadata.teams
transformer = self.get_transformer(
length=sportec_metadata.x_max, width=sportec_metadata.y_max
Expand Down
16 changes: 6 additions & 10 deletions kloppy/infra/serializers/tracking/sportec/deserializer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import logging
from collections import defaultdict
from typing import Tuple, Dict, NamedTuple, Optional, Union, IO, Literal
from typing import Tuple, NamedTuple, Optional, Union, IO

from lxml import objectify

Expand All @@ -12,24 +11,21 @@
Frame,
Point,
Point3D,
Team,
BallState,
Period,
Provider,
Orientation,
attacking_direction_from_frame,
Metadata,
Ground,
Player,
build_coordinate_system,
Provider,
PlayerData,
)

from kloppy.utils import Readable, performance_logging
from kloppy.utils import performance_logging

from ..deserializer import TrackingDataDeserializer
from ...event.sportec.deserializer import _sportec_metadata_from_xml_elm
from kloppy.infra.serializers.event.sportec.deserializer import (
sportec_metadata_from_xml_elm,
)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -121,7 +117,7 @@ def deserialize(
data_root = objectify.fromstring(inputs.raw_data.read())

with performance_logging("parse metadata", logger=logger):
sportec_metadata = _sportec_metadata_from_xml_elm(match_root)
sportec_metadata = sportec_metadata_from_xml_elm(match_root)
teams = home_team, away_team = sportec_metadata.teams
periods = sportec_metadata.periods
transformer = self.get_transformer(
Expand Down

0 comments on commit 2034364

Please sign in to comment.