Exemplo n.º 1
0
 def test_sort_raw_data(self):
     """Tests whether the raw data is sorted properly."""
     home,tmp,tmp2,tmp3 = impire_parser.read_in_position_data(TestMatchPosition.pos_file)
     home_s = impire_parser.sort_position_data(home,0)
     test_array = np.arange(7) + 1.0
     target_array = [d for d in home_s if np.all(d[:,0]==15.0)][0][:,1]
     self.assertTrue(np.all(target_array == test_array))
Exemplo n.º 2
0
 def test_pos_role_combination(self):
     """Tests whether the merging of position data and role works."""
     mip = impire_parser.MatchInformationParser()
     mip.run(TestMatchPosition.match_file)
     teams, match = mip.getTeamInformation()
     home,guest,ball,half_time_id = impire_parser.read_in_position_data(TestMatchPosition.pos_file)
     home_1, home_2 = impire_parser.split_positions_into_game_halves(home,half_time_id,ball)
     home_1s = impire_parser.sort_position_data(home_1)
     pos_data_home_1 = impire_parser.combine_position_with_role(home_1s,teams['home'])
     # Han Solo is the test case: Trikot: 24, ID: 10005
     test_case = filter(lambda x: x[0] == '10005', pos_data_home_1)[0]
     self.assertTrue(np.all(test_case[1][2,:] == (2,-0.0825,-0.4624)))
     # Cin Drallig - Trikot: 17, ID: 11002
     guest_1, guest_2 = impire_parser.split_positions_into_game_halves(guest,half_time_id,ball)
     guest_2s = impire_parser.sort_position_data(guest_2)
     pos_data_guest_2 = impire_parser.combine_position_with_role(guest_2s, teams['guest'])
     test_case = filter(lambda x: x[0] == '11002', pos_data_guest_2)[0]
     self.assertTrue(np.all(test_case[1][1,:] == (37043,-0.2715,0.1733)))
Exemplo n.º 3
0
    def test_split_and_sort(self):
        """Test processing chain after sorting."""
        home,tmp2,ball,ht = impire_parser.read_in_position_data(TestMatchPosition.pos_file)
        home_1,home_2 = impire_parser.split_positions_into_game_halves(home,ht,ball)
        home_1s = impire_parser.sort_position_data(home_1)

        self.assertTrue(np.all(map(lambda x: x.shape == (4,4), home_1s)))
        test_data = next(p for p in home_1s if p[0,1] == 2)
        self.assertTrue(np.all(test_data[:,1] == 2.0))
        self.assertTrue(test_data[0,2] == -11.9269)
Exemplo n.º 4
0
 def test_sort_raw_data2(self):
     """Tests sequence of raw data."""
     data = impire_parser.read_in_position_data(TestMatchPosition.pos_file)
     home_s = impire_parser.sort_position_data(data[0],0)
     self.assertTrue(home_s[9][0,1] == -11.0)