def test_cobweb_ifit():
    tree = CobwebTree()
    tree.ifit({'a': 'b'})

    assert tree.root.count == 1
    assert len(tree.root.children) == 0
    assert 'a' in tree.root.av_counts
    assert 'b' in tree.root.av_counts['a']
def test_cobweb_clear():
    tree = CobwebTree()
    tree.ifit({'a': 'b'})
    tree.clear()

    assert tree.root.count == 0
    assert isinstance(tree.root, CobwebNode)
    assert tree == tree.root.tree
def test_cobweb():
    tree = CobwebTree()
    for i in range(40):
        data = {}
        data['a1'] = random.choice(['v1', 'v2', 'v3', 'v4'])
        data['a2'] = random.choice(['v1', 'v2', 'v3', 'v4'])
        tree.ifit(data)
    verify_counts(tree.root)
def test_empty_instance():
    t = CobwebTree()
    t.ifit({'x': 1})
    t.ifit({'x': 2})
    t.categorize({})