def test_set_obsm_key(adata):
    init_hash = joblib.hash(adata)

    orig_obsm_val = adata.obsm["o"].copy()
    subset_obsm = adata[:50]
    assert subset_obsm.is_view
    subset_obsm.obsm["o"] = np.ones((50, 20))
    assert not subset_obsm.is_view
    assert np.all(adata.obsm["o"] == orig_obsm_val)

    assert init_hash == joblib.hash(adata)
def exiter_as(cls, new_exiter_fun: Callable[[Optional[Exiter]], Exiter]) -> Iterator[None]:
        """Temporarily override the global exiter.

        NB: We don't want to try/finally here, because we want exceptions to propagate
        with the most recent exiter installed in sys.excepthook.
        If we wrap this in a try:finally, exceptions will be caught and exiters unset.
        """
        previous_exiter = cls._exiter
        new_exiter = new_exiter_fun(previous_exiter)
        cls._reset_exiter(new_exiter)
        yield
        cls._reset_exiter(previous_exiter)