Пример #1
0
 def __init__(self, line_segment, trajectory_id, position_in_trajectory=None):
     ClusterCandidate.__init__(self)
     if line_segment == None or trajectory_id < 0:
         raise Exception
     
     self.line_segment = line_segment
     self.trajectory_id = trajectory_id
     self.position_in_trajectory = position_in_trajectory
     self.num_neighbors = -1
Пример #2
0
    def test_calls_dist_to_other_candidate_when_finding_candidates(self):
        counter = MutableFloat(0)

        def mock_dist_to_other_candidate_func(other_candidate):
            counter.increment(1)
            return 0

        candidate = ClusterCandidate()
        candidate.distance_to_candidate = mock_dist_to_other_candidate_func
        candidate.find_neighbors([1, 2, 3, 4, 5], epsilon=0)
        self.assertEquals(counter.get_val(), 5)
 def test_calls_dist_to_other_candidate_when_finding_candidates(self):
     counter = MutableFloat(0)
     
     def mock_dist_to_other_candidate_func(other_candidate):
         counter.increment(1)
         return 0
    
     candidate = ClusterCandidate()
     candidate.distance_to_candidate = mock_dist_to_other_candidate_func
     candidate.find_neighbors([1, 2, 3, 4, 5], epsilon=0)
     self.assertEquals(counter.get_val(), 5)        
Пример #4
0
 def find_neighbors(self, candidates, epsilon):
     neighbors = ClusterCandidate.find_neighbors(self, candidates, epsilon)
     if self.num_neighbors != -1 and self.num_neighbors != len(neighbors):
         raise Exception("neighbors count should never be changing")
     self.num_neighbors = len(neighbors)
     return neighbors
Пример #5
0
 def __init__(self, x, y):
     ClusterCandidate.__init__(self)
     self.point = Point(x, y)
Пример #6
0
 def __init__(self, x, y):
     ClusterCandidate.__init__(self)
     self.point = Point(x, y)