def test_modify_view_component(matrix_type, mapping_name):
    adata = ad.AnnData(
        np.zeros((10, 10)),
        **{mapping_name: dict(m=matrix_type(asarray(sparse.random(10, 10))))},
    )
    init_hash = joblib.hash(adata)

    subset = adata[:5, :][:, :5]
    assert subset.is_view
    m = getattr(subset, mapping_name)["m"]
    m[0, 0] = 100
    assert not subset.is_view
    assert getattr(subset, mapping_name)["m"][0, 0] == 100

    assert init_hash == joblib.hash(adata)
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)