def test_num_neighbor_counting(self):
     line_segment = TrajectoryLineSegment(self.create_simple_line_seg((0, 0), (1, 1)), 1)
     line_segment.distance_to_candidate = lambda x: 0.0
     mock_canididates = [1, 2, 3, 4, 5, 6]
     self.assertRaises(Exception, line_segment.get_num_neighbors)
     line_segment.find_neighbors(candidates=mock_canididates, epsilon=0.1)
     self.assertEquals(line_segment.get_num_neighbors(), 6)
示例#2
0
 def test_two_short_line_endpoints_get_picked(self):
     lines = [LineSegment.from_points([Point(0, 0), Point(1, 0)]), \
              LineSegment.from_points([Point(0, 1), Point(1, 1)])]
     traj_lines = [TrajectoryLineSegment(lines[0], 0), \
                   TrajectoryLineSegment(lines[1], 1)]
     res = get_representative_trajectory_average_inputs(trajectory_line_segments=traj_lines, \
                                                       min_prev_dist=1, min_lines=2)
     expected = 2
     self.assertEquals(len(res), expected)
示例#3
0
 def test_four_line_sets_should_result(self):
     lines = [LineSegment.from_points([Point(0, 0), Point(1, 0)]), \
              LineSegment.from_points([Point(0.5, 1), Point(1.5, 1)])]
     traj_lines = [TrajectoryLineSegment(lines[0], 0), \
                   TrajectoryLineSegment(lines[1], 1)]
     res = get_representative_trajectory_average_inputs(trajectory_line_segments=traj_lines, \
                                                       min_prev_dist=0.5, min_lines=1)
     expected = 4
     self.assertEquals(len(res), expected)
示例#4
0
 def test_trajectory_factory(self):
     line_seg = self.create_simple_line_seg((0, 0), (1, 1))
     expected = TrajectoryLineSegment(line_seg, 1)
     res = TrajectoryLineSegmentFactory().new_trajectory_line_seg(
         line_seg, trajectory_id=1)
     self.assertEquals(res.line_segment, expected.line_segment)
     self.assertEquals(res.trajectory_id, expected.trajectory_id)
示例#5
0
 def create_trajectory_line_seg(self,
                                start,
                                end,
                                traj_id,
                                original_position=None):
     return TrajectoryLineSegment(LineSegment.from_points([Point(start[0], start[1]), \
                                                           Point(end[0], end[1])]), traj_id, original_position)
示例#6
0
 def create_line(self,
                 horizontal_start,
                 horizontal_end,
                 line_set_ids,
                 trajectory_id,
                 orig_pos=None):
     if orig_pos == None:
         orig_pos = random.randint(0, 1000)
     return {'trajectory_line_segment': \
             TrajectoryLineSegment(LineSegment.from_points([Point(horizontal_start, random.randint(0, 1000)), \
                                                            Point(horizontal_end, random.randint(0, 1000))]), \
                                   trajectory_id, orig_pos), \
             'line_set_ids': line_set_ids}
示例#7
0
 def test_num_neighbor_counting(self):
     line_segment = TrajectoryLineSegment(
         self.create_simple_line_seg((0, 0), (1, 1)), 1)
     line_segment.distance_to_candidate = lambda x: 0.0
     mock_canididates = [1, 2, 3, 4, 5, 6]
     self.assertRaises(Exception, line_segment.get_num_neighbors)
     line_segment.find_neighbors(candidates=mock_canididates, epsilon=0.1)
     self.assertEquals(line_segment.get_num_neighbors(), 6)