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 _reset_exiter(cls, exiter: Optional[Exiter]) -> None:
        """Class state:

        - Overwrites `cls._exiter`.
        Python state:
        - Overwrites sys.excepthook.
        """
        logger.debug(f"overriding the global exiter with {exiter} (from {cls._exiter})")
        # NB: mutate the class variables! This is done before mutating the exception hook, because the
        # uncaught exception handler uses cls._exiter to exit.
        cls._exiter = exiter
        # NB: mutate process-global state!
        sys.excepthook = cls._log_unhandled_exception_and_exit