def test_deepcopy_subset(adata, spmat: type):
    adata.obsp["arr"] = np.zeros((adata.n_obs, adata.n_obs))
    adata.obsp["spmat"] = spmat((adata.n_obs, adata.n_obs))

    adata = deepcopy(adata[:10].copy())

    assert isinstance(adata.obsp["arr"], np.ndarray)
    assert not isinstance(adata.obsp["arr"], ArrayView)
    np.testing.assert_array_equal(adata.obsp["arr"].shape, (10, 10))

    assert isinstance(adata.obsp["spmat"], spmat)
    assert not isinstance(
        adata.obsp["spmat"],
        SparseCSRView if spmat is sparse.csr_matrix else SparseCSCView,
    )
    np.testing.assert_array_equal(adata.obsp["spmat"].shape, (10, 10))
def _globpatsplit(pat):
    """Split a glob pattern. Return a list.

    A naive version is "path.split("/")". This function handles more cases, like
    "{*,{a,b}*/*}".

    >>> _globpatsplit("*/**/x/{a,b/c}")
    ['*', '**', 'x', '{a,b/c}']
    """
    result = []
    buf = ""
    parentheses = 0
    for ch in pat:
        if ch == "{":
            parentheses += 1
        elif ch == "}":
            parentheses -= 1
        if parentheses == 0 and ch == "/":
            if buf:
                result.append(buf)
                buf = ""
        else:
            buf += ch
    if buf:
        result.append(buf)
    return result