Example #1
0
 def compress(self):
     T = TDigest(self.delta, self.K)
     C = list(self.C.values())
     if len(C) > 0:
         for c_i in pyudorandom.items(C):
             T.update(c_i.mean, c_i.count)
     self.C = T.C
Example #2
0
    def __add__(self, other_digest):
        data = list(chain(self.C.values(), other_digest.C.values()))
        new_digest = TDigest(self.delta, self.K)

        if len(data) > 0:
            for c in pyudorandom.items(data):
                new_digest.update(c.mean, c.count)

        return new_digest
Example #3
0
    def __add__(self, other_digest):
        data = list(chain(self.C.values(), other_digest.C.values()))
        new_digest = TDigest(self.delta, self.K)
        
        if len(data) > 0:
            for c in pyudorandom.items(data):
                new_digest.update(c.mean, c.count)

        return new_digest
    def __add__(self, other_digest):
        data = list(chain(self.C.values(), other_digest.C.values()))
        new_digest = TDigest(self.delta, self.K)

        ###################################
        # New added sorting mechanisms
        ###################################
        if self.merge_sorting == "centroid_order":
            data = sorted(data, key=lambda x: x.mean, reverse=True)
        elif self.merge_sorting == "centroid_size":
            data = sorted(data, key=lambda x: x.count, reverse=True)
        ###################################
        ###################################

        if len(data) > 0:
            if self.merge_sorting is None:
                for c in pyudorandom.items(data):
                    new_digest.update(c.mean, c.count)
            else:
                for c in data:
                    new_digest.update(c.mean, c.count)

        return new_digest
 def test_items(self):
     my_list = range(50)
     generated = list(items(my_list))
     self.assertNotEqual(generated, my_list)
     self.assertEqual(set(generated), set(my_list))
 def test_items_empty(self):
     my_list = []
     my_items = items(my_list)
     self.assertFalse(list(my_items))
     self.assertEqual(list(my_items), my_list)
Example #7
0
 def compress(self):
     T = TDigest(self.delta, self.K)
     C = list(self.C.values())
     for c_i in pyudorandom.items(C):
         T.update(c_i.mean, c_i.count)
     self.C = T.C
Example #8
0
 def test_items(self):
     my_list = range(50)
     generated = list(items(my_list))
     self.assertNotEqual(generated, my_list)
     self.assertEqual(set(generated), set(my_list))
Example #9
0
 def test_items_empty(self):
     my_list = []
     my_items = items(my_list)
     self.assertFalse(list(my_items))
     self.assertEqual(list(my_items), my_list)