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

    dim0_size = np.random.randint(2, adata.shape[0] - 1)
    dim1_size = np.random.randint(1, 99)
    orig_obsm_val = adata.obsm["o"].copy()
    subset_idx = np.random.choice(adata.obs_names, dim0_size, replace=False)

    subset = adata[subset_idx, :]
    assert subset.is_view
    subset.obsm = dict(o=np.ones((dim0_size, dim1_size)))
    assert not subset.is_view
    assert np.all(orig_obsm_val == adata.obsm["o"])  # Checking for mutation
    assert np.all(subset.obsm["o"] == np.ones((dim0_size, dim1_size)))

    subset = adata[subset_idx, :]
    subset_hash = joblib.hash(subset)
    with pytest.raises(ValueError):
        subset.obsm = dict(o=np.ones((dim0_size + 1, dim1_size)))
    with pytest.raises(ValueError):
        subset.varm = dict(o=np.ones((dim0_size - 1, dim1_size)))
    assert subset_hash == joblib.hash(subset)

    # Only modification have been made to a view
    assert init_hash == joblib.hash(adata)
def commit_and_push(repo_dir, day):
    subprocess.check_call(
        ["git", "config", "--global", "user.email", "u1test+m-o@canonical.com"]
    )
    subprocess.check_call(["git", "config", "--global", "user.name", "snappy-m-o"])

    subprocess.check_call(["git", "-C", repo_dir, "add", "--all"])
    subprocess.check_call(
        [
            "git",
            "-C",
            repo_dir,
            "commit",
            "--message",
            "Add the results for {}".format(day),
        ]
    )

    subprocess.check_call(
        [
            "git",
            "-C",
            repo_dir,
            "push",
            "https://{GH_TOKEN}@github.com/elopio/autopkgtest-results.git".format(
                GH_TOKEN=os.environ.get("GH_TOKEN_PPA_AUTOPKGTEST_RESULTS")
            ),
        ]
    )