def test_set_var(adata, subset_func):
    init_hash = joblib.hash(adata)

    subset = adata[:, subset_func(adata.var_names)]

    new_var = pd.DataFrame(
        dict(a=np.ones(subset.n_vars), b=np.ones(subset.n_vars)),
        index=subset.var_names,
    )

    assert subset.is_view
    subset.var = new_var
    assert not subset.is_view
    assert np.all(subset.var == new_var)

    assert joblib.hash(adata) == init_hash
def test_parse_section_body():
    output_section = {
        'action_template': '    task',
        'sources_repls': 'source',
        'variable': '6',
        'target_pattern': 'target',
    }
    assert mariofile.parse_section_body(SECTION.splitlines(True)) == output_section
    with pytest.raises(mariofile.ConfigurationFileError):
        mariofile.parse_section_body(SECTION_MULTIPLE_RULE.splitlines(True))
    with pytest.raises(mariofile.ConfigurationFileError):
        mariofile.parse_section_body(INVALID_CONFIG.splitlines(True))