def test_constructor():
    HyperLogLog()
    HyperLogLog(b=4)
    try:
        HyperLogLog(b=17)
        raise Exception("Should have thrown an InvalidParameter exception")
    except InvalidParameters:
        pass
Пример #2
0
def test_add():
    t1 = HyperLogLog(b=4)
    t1.add("TEST1")
    assert any(t1.M)

    Mmax = max(t1.M)

    t1.add("TEST1")
    assert Mmax == max(t1.M)
def test_add():
    t1 = HyperLogLog(b=4)
    t1.add("TEST1")
    assert any(t1.M)

    Mmax = max(t1.M)

    t1.add("TEST1")
    assert Mmax == max(t1.M)
Пример #4
0
def test_union():
    t1 = HyperLogLog(range(10), b=5)
    t2 = HyperLogLog(range(10), b=5)
    t3 = HyperLogLog(range(20), b=5)

    t1.union(t2)
    assert set(t1.M) == set(t2.M)

    t1.union(t3)
    assert set(t1.M) == set(t3.M)

    t4 = HyperLogLog(range(10), b=4)
    try:
        t1.union(t4)
        raise Exception("Should have complained about parameters")
    except:
        pass
    },
    {
        "name": "Log Log Register",
        "obj": LLRegister(),
    },
    {
        "name": "LogLog",
        "obj": LL(16),
    },
    {
        "name": "SuperLogLog",
        "obj": SuperLL(16),
    },
    {
        "name": "HyperLogLog",
        "obj": HyperLogLog(b=16),
    },
    {
        "name": "KMinValues",
        "obj": KMinValues(k=1 << 16),
    },
    {
        "name": "ScalingBloom",
        "obj": ScalingBloomFilter(1048576),
    },
]


@contextmanager
def TimerBlock(name):
    start = time.time()
def test_union():
    t1 = HyperLogLog(range(10), b=5)
    t2 = HyperLogLog(range(10), b=5)
    t3 = HyperLogLog(range(20), b=5)

    t1.union(t2)
    assert set(t1.M) == set(t2.M)

    t1.union(t3)
    assert set(t1.M) == set(t3.M)

    t4 = HyperLogLog(range(10), b=4)
    try:
        t1.union(t4)
        raise Exception("Should have complained about parameters")
    except:
        pass
def test_rho():
    t1 = HyperLogLog()
    assert 1 == t1.rho(0b10101010101, width=11)
    assert 4 == t1.rho(0b00011010101, width=11)
    assert 5 == t1.rho(0b0000, width=4)
Пример #8
0
def test_rho():
    t1 = HyperLogLog()
    assert 1 == t1.rho(0b10101010101, width=11)
    assert 4 == t1.rho(0b00011010101, width=11)
    assert 5 == t1.rho(0b0000, width=4)