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 _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