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)))
    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)
 def test_half_time_split(self):
     """Tests the splitting of the position data into two halves."""
     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)
     self.assertTrue(home_1.shape == (4,11,4))
     self.assertTrue(home_2.shape == (3,11,4))