def test_view_setattr_machinery(attr, subset_func, subset_func2):
    # Tests that setting attributes on a view doesn't mess anything up too bad
    adata = gen_adata((10, 10))
    view = adata[subset_func(adata.obs_names), subset_func2(adata.var_names)]

    actual = view.copy()
    setattr(view, attr, getattr(actual, attr))
    assert_equal(actual, view, exact=True)
def test():
    start = time.time()
    treap = None
    s = set()
    for i in range(100000):
        key = random.randint(0, 10000)
        if random.randint(0, 1) == 0:
            if key in s:
                treap = remove(treap, key)
                s.remove(key)
        elif key not in s:
            treap = insert(treap, key)
            s.add(key)
        assert len(s) == size(treap)

    for i in range(size(treap)):
        assert kth(treap, i) in s
    print(time.time() - start)