Exemplo n.º 1
0
 def test_all(self):
     num = MutableFloat(1.0)
     num.increment(3)
     num.increment(5)
     num.multiply(2)
     num.multiply(2)
     self.assertEquals(36, num.get_val())
Exemplo n.º 2
0
 def test_all(self):
     num = MutableFloat(1.0)
     num.increment(3)
     num.increment(5)
     num.multiply(2)
     num.multiply(2)
     self.assertEquals(36, num.get_val())
Exemplo n.º 3
0
 def test_closurability(self):
     num = MutableFloat(1.0)
     def add(other):
         num.increment(other)
         
     add(2.0)
     add(3.0)
     add(10)
     self.assertEquals(16, num.get_val())
Exemplo n.º 4
0
    def test_closurability(self):
        num = MutableFloat(1.0)

        def add(other):
            num.increment(other)

        add(2.0)
        add(3.0)
        add(10)
        self.assertEquals(16, num.get_val())
 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()
     index = ClusterCandidateIndex([1, 2, 3, 4, 5], epsilon=0)
     candidate.distance_to_candidate = mock_dist_to_other_candidate_func
     index.find_neighbors_of(cluster_candidate=candidate)
     self.assertEquals(counter.get_val(), 5)