def test_modify_view_component(matrix_type, mapping_name):
    adata = ad.AnnData(
        np.zeros((10, 10)),
        **{mapping_name: dict(m=matrix_type(asarray(sparse.random(10, 10))))},
    )
    init_hash = joblib.hash(adata)

    subset = adata[:5, :][:, :5]
    assert subset.is_view
    m = getattr(subset, mapping_name)["m"]
    m[0, 0] = 100
    assert not subset.is_view
    assert getattr(subset, mapping_name)["m"][0, 0] == 100

    assert init_hash == joblib.hash(adata)
def test_when_verbose_and_retcode_is_nonzero_output_should_be_had():
    expected_stderr = "this is something fnord"
    with patch.dict(
        pdbedit.__salt__,
        {
            "cmd.run_all": MagicMock(
                return_value={"stdout": "", "stderr": expected_stderr, "retcode": 1}
            )
        },
    ), patch("salt.modules.pdbedit.log.error", autospec=True) as fake_error_log:
        pdbedit.list_users(verbose=True)
        actual_error = fake_error_log.mock_calls[0].args[0]
        assert actual_error == expected_stderr