def test_set_subset_varm(adata, subset_func):
    init_hash = joblib.hash(adata)
    orig_varm_val = adata.varm["o"].copy()

    while True:
        subset_idx = slice_subset(adata.var_names)
        if (adata[:, subset_idx]).shape[1] > 2:
            break
    subset = adata[:, subset_idx]

    internal_idx = _normalize_index(
        subset_func(np.arange(subset.varm["o"].shape[0])), subset.var_names
    )

    assert subset.is_view
    subset.varm["o"][internal_idx] = 1
    assert not subset.is_view
    assert np.all(adata.varm["o"] == orig_varm_val)

    assert init_hash == joblib.hash(adata)
def _convertretoglobs(repat):
    """Attempt to convert a regular expression pattern to glob patterns.

    A single regular expression pattern might be converted into multiple
    glob patterns.

    Return None if conversion is unsupported.

    >>> _convertretoglobs("abc*") is None
    True
    >>> _convertretoglobs("xx/yy/(?!zz/kk)")
    ['xx/yy/**', '!xx/yy/zz/kk/**']
    >>> _convertretoglobs("x/y/(?:.*/)?BUCK")
    ['x/y/**/BUCK']
    """
    m = _repat1.match(repat)
    if m:
        prefix, excluded = m.groups()
        return ["%s/**" % prefix, "!%s/%s/**" % (prefix, excluded)]
    m = _repat2.match(repat)
    if m:
        prefix, name = m.groups()
        return ["%s/**/%s" % (prefix, name)]
    return None