-
Notifications
You must be signed in to change notification settings - Fork 23
/
Game.py
32 lines (26 loc) · 899 Bytes
/
Game.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pandas as pd
from Event import Event
from Team import Team
from Constant import Constant
import numpy as np
class Game:
"""A class for keeping info about the games"""
def __init__(self, path_to_json):
# self.events = None
self.home_team = None
self.guest_team = None
self.event = None
self.path_to_json = path_to_json
def read_json(self):
data_frame = pd.read_json(self.path_to_json)
last_default_index = len(data_frame) - 1
all_trajs = []
for i in range(last_default_index):
event = data_frame['events'][i]
self.event = Event(event)
trajs = self.event.get_traj() # (N,15,11,2)
if len(trajs) > 0:
all_trajs.append(trajs)
# print(i,len(trajs))
all_trajs = np.concatenate(all_trajs,axis=0)
return all_trajs