Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 4, 2024
1 parent 69f73c1 commit dc556f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 7 additions & 5 deletions ehrapy/anndata/anndata_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,13 @@ def delete_from_obs(adata: AnnData, to_delete: list[str]) -> AnnData:
return adata


def move_to_x(adata: AnnData,
to_x: list[str] | str,
copy_uns: bool = True,
copy_obsm: bool= True,
copy_varm: bool= True,) -> AnnData:
def move_to_x(
adata: AnnData,
to_x: list[str] | str,
copy_uns: bool = True,
copy_obsm: bool = True,
copy_varm: bool = True,
) -> AnnData:
"""Move features from obs to X inplace.
Args:
Expand Down
6 changes: 5 additions & 1 deletion tests/anndata/test_anndata_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,25 @@ def test_move_to_x(adata_move_obs_mix):
).astype({"clinic_id": "float32", "name": "category"}),
)


def test_move_to_x_copy_uns(adata_move_obs_mix):
adata_move_obs_mix.uns["test"] = "test"
new_adata = move_to_x(adata_move_obs_mix, ["name"], copy_uns=True)
assert "test" in new_adata.uns



def test_move_to_x_copy_obsm(adata_move_obs_mix):
adata_move_obs_mix.obsm["test"] = np.random.rand(adata_move_obs_mix.n_obs, 5)
new_adata = move_to_x(adata_move_obs_mix, ["name"], copy_obsm=True)
assert "test" in new_adata.obsm


def test_move_to_x_copy_varm(adata_move_obs_mix):
adata_move_obs_mix.varm["test"] = np.random.rand(adata_move_obs_mix.n_vars, 5)
new_adata = move_to_x(adata_move_obs_mix, ["name"], copy_varm=True)
assert "test" in new_adata.varm


def test_move_to_x_invalid_column_names(adata_move_obs_mix):
move_to_obs(adata_move_obs_mix, ["name"], copy_obs=True)
move_to_obs(adata_move_obs_mix, ["clinic_id"], copy_obs=False)
Expand Down

0 comments on commit dc556f5

Please sign in to comment.