Beispiel #1
0
 def test_add(self):
     s = zset()
     s.add(3, 'ciao')
     s.add(4, 'bla')
     self.assertEqual(len(s), 2)
     s.add(-1, 'bla')
     self.assertEqual(len(s), 2)
     data = list(s)
     self.assertEqual(data, ['bla', 'ciao'])
Beispiel #2
0
 def test_add(self):
     s = zset()
     s.add(3, 'ciao')
     s.add(4, 'bla')
     self.assertEqual(len(s), 2)
     s.add(-1, 'bla')
     self.assertEqual(len(s), 2)
     data = list(s)
     self.assertEqual(data, ['bla', 'ciao'])
Beispiel #3
0
 def test_update(self):
     string = test.populate('string', size=100)
     values = test.populate('float', size=100)
     s = zset()
     s.update(zip(values, string))
     self.assertTrue(s)
     prev = None
     for score, _ in s.items():
         if prev is not None:
             self.assertTrue(score >= prev)
         prev = score
     return s
Beispiel #4
0
 def test_update(self):
     string = test.populate('string', size=100)
     values = test.populate('float', size=100)
     s = zset()
     s.update(zip(values,string))
     self.assertTrue(s)
     prev = None
     for score, _ in s.items():
         if prev is not None:
             self.assertTrue(score>=prev)
         prev = score
     return s
Beispiel #5
0
 def test_rank(self):
     s = zset()
     s.add(3, 'ciao')
     s.add(4, 'bla')
     s.add(2, 'foo')
     s.add(20, 'pippo')
     s.add(-1, 'bla')
     self.assertEqual(len(s), 4)
     self.assertEqual(s.rank('bla'), 0)
     self.assertEqual(s.rank('foo'), 1)
     self.assertEqual(s.rank('ciao'), 2)
     self.assertEqual(s.rank('pippo'), 3)
     self.assertEqual(s.rank('xxxx'), None)
Beispiel #6
0
 def test_rank(self):
     s = zset()
     s.add(3, 'ciao')
     s.add(4, 'bla')
     s.add(2, 'foo')
     s.add(20, 'pippo')
     s.add(-1, 'bla')
     self.assertEqual(len(s), 4)
     self.assertEqual(s.rank('bla'), 0)
     self.assertEqual(s.rank('foo'), 1)
     self.assertEqual(s.rank('ciao'), 2)
     self.assertEqual(s.rank('pippo'), 3)
     self.assertEqual(s.rank('xxxx'), None)
Beispiel #7
0
 def set_cache(self, data):
     if self.cache is None:
         self.cache = zset()
     self.cache.update(data)
Beispiel #8
0
 def clear(self):
     self.cache = None
     self.toadd = zset()
     self.toremove = set()
Beispiel #9
0
 def set_cache(self, data):
     if self.cache is None:
         self.cache = zset()
     self.cache.update(data)
Beispiel #10
0
 def clear(self):
     self.cache = None
     self.toadd = zset()
     self.toremove = set()