Esempio n. 1
0
    def test_update(self):
        hll1 = HyperLogLog({'foo', 'bar', 'zap', 'a'})
        hll2 = HyperLogLog({'a', 'b', 'c', 'foo'})
        hll1.update(hll2)
        assert len(hll1) == 6

        hll1 = HyperLogLog({'foo', 'bar', 'zap', 'a'})
        hll1.update({'b', 'c', 'd', 'foo'})
        assert len(hll1) == 7

        hll1 = HyperLogLog({'foo', 'bar', 'zap', 'a'})
        hll1.update(hll2, {'b', 'c', 'd', 'baz'})
        assert len(hll1) == 8
Esempio n. 2
0
 def test_repr(self):
     'Test HyperLogLog.__repr__()'
     hll = HyperLogLog({'foo', 'bar', 'zap', 'a'}, key=self._KEY)
     assert repr(hll) == f'<HyperLogLog key={self._KEY} len=4>'
Esempio n. 3
0
 def test_union(self):
     hll1 = HyperLogLog({'foo', 'bar', 'zap', 'a'})
     hll2 = HyperLogLog({'a', 'b', 'c', 'foo'})
     assert len(hll1.union(hll2)) == 6
     assert len(hll1.union({'b', 'c', 'd', 'foo'})) == 7
     assert len(hll1.union(hll2, {'b', 'c', 'd', 'baz'})) == 8
Esempio n. 4
0
    def test_update(self):
        hll1 = HyperLogLog({'foo', 'bar', 'zap', 'a'})
        hll2 = HyperLogLog({'a', 'b', 'c', 'foo'})
        hll1.update(hll2)
        assert len(hll1) == 6

        hll1 = HyperLogLog({'foo', 'bar', 'zap', 'a'})
        hll1.update({'b', 'c', 'd', 'foo'})
        assert len(hll1) == 7

        hll1 = HyperLogLog({'foo', 'bar', 'zap', 'a'})
        hll1.update(hll2, {'b', 'c', 'd', 'baz'})
        assert len(hll1) == 8
Esempio n. 5
0
    def test_add(self):
        hll = HyperLogLog()
        hll.add('foo')
        assert len(hll) == 1

        hll.add('bar')
        assert len(hll) == 2

        hll.add('zap')
        assert len(hll) == 3

        hll.add('a')
        assert len(hll) == 4

        hll.add('a')
        assert len(hll) == 4

        hll.add('b')
        assert len(hll) == 5

        hll.add('c')
        assert len(hll) == 6

        hll.add('foo')
        assert len(hll) == 6
Esempio n. 6
0
 def test_init_with_iterable(self):
     hll = HyperLogLog({'foo', 'bar', 'zap', 'a'})
     assert len(hll) == 4
Esempio n. 7
0
 def test_init_without_iterable(self):
     hll = HyperLogLog()
     assert len(hll) == 0
Esempio n. 8
0
 def test_repr(self):
     'Test HyperLogLog.__repr__()'
     hll = HyperLogLog({'foo', 'bar', 'zap', 'a'}, key='hll')
     assert repr(hll) == '<HyperLogLog key=hll len=4>'
Esempio n. 9
0
 def test_union(self):
     hll1 = HyperLogLog({'foo', 'bar', 'zap', 'a'})
     hll2 = HyperLogLog({'a', 'b', 'c', 'foo'})
     assert len(hll1.union(hll2)) == 6
     assert len(hll1.union({'b', 'c', 'd', 'foo'})) == 7
     assert len(hll1.union(hll2, {'b', 'c', 'd', 'baz'})) == 8
Esempio n. 10
0
    def test_add(self):
        hll = HyperLogLog()
        hll.add('foo')
        assert len(hll) == 1

        hll.add('bar')
        assert len(hll) == 2

        hll.add('zap')
        assert len(hll) == 3

        hll.add('a')
        assert len(hll) == 4

        hll.add('a')
        assert len(hll) == 4

        hll.add('b')
        assert len(hll) == 5

        hll.add('c')
        assert len(hll) == 6

        hll.add('foo')
        assert len(hll) == 6