コード例 #1
0
ファイル: test_hyper.py プロジェクト: brainix/pottery
    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
コード例 #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>'
コード例 #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
コード例 #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
コード例 #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
コード例 #6
0
 def test_init_with_iterable(self):
     hll = HyperLogLog({'foo', 'bar', 'zap', 'a'})
     assert len(hll) == 4
コード例 #7
0
 def test_init_without_iterable(self):
     hll = HyperLogLog()
     assert len(hll) == 0
コード例 #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>'
コード例 #9
0
ファイル: test_hyper.py プロジェクト: brainix/pottery
 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
コード例 #10
0
ファイル: test_hyper.py プロジェクト: brainix/pottery
    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