def test_view_delattr(attr, subset_func):
    base = gen_adata((10, 10))
    orig_hash = joblib.hash(base)
    subset = base[subset_func(base.obs_names), subset_func(base.var_names)]
    empty = ad.AnnData(obs=subset.obs[[]], var=subset.var[[]])

    delattr(subset, attr)

    assert not subset.is_view
    # Should now have same value as default
    assert_equal(getattr(subset, attr), getattr(empty, attr))
    assert orig_hash == joblib.hash(base)  # Original should not be modified
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