def test_set_subset_obsm(adata, subset_func):
    init_hash = joblib.hash(adata)
    orig_obsm_val = adata.obsm["o"].copy()

    while True:
        subset_idx = slice_subset(adata.obs_names)
        if len(adata[subset_idx, :]) > 2:
            break
    subset = adata[subset_idx, :]

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

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

    assert init_hash == joblib.hash(adata)
def log_stream(self, logger_name, level_name, format_str):
        """ Attaches a log handler to the specified logger and sends emitted logs 
            back as stream. 
        """
        if logger_name != "" and logger_name not in self.available_loggers():
            raise ValueError("logger {0} is not available".format(logger_name))

        level_name_upper = level_name.upper() if level_name else "NOTSET"
        try:
            level = getattr(logging, level_name_upper)
        except AttributeError, e:
            raise AttributeError("log level {0} is not available".format(level_name_upper))