Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ and this project adheres to [Semantic Versioning][].

- `update()`, `push_obs()`, `push_var()`, `pull_obs()`, and `pull_var()` now try harder to preserve the dtype of the dataframe columns

### Deprecated

- `MuData.mod_names`, `MuData.obs_keys`, `MuData.var_keys`, `MuData.obsm_keys`, `MuData.varm_keys`, `MuData.uns_keys`, `MuData.obs_vector`, `MuData.var_vector`.
Their analogs in AnnData will be deprecated in AnnData 0.13.

## [0.3.3]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = [
"numpy",
"pandas>=1.4",
"scipy",
"scverse-misc",
"scverse-misc>=0.0.3",
# for debug logging (referenced from the issue template)
"session-info2",
]
Expand Down
9 changes: 9 additions & 0 deletions src/mudata/_core/mudata.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from anndata._core.aligned_mapping import AxisArraysBase
from anndata._core.views import DataFrameView
from anndata.utils import convert_to_dict
from scverse_misc import Deprecation, deprecated

from .compat import AlignedView, AxisArrays, PairwiseArrays
from .config import OPTIONS
Expand Down Expand Up @@ -1248,6 +1249,7 @@ def _attr_vector(self, key: str, attr: str) -> np.ndarray:
raise KeyError(f"There is no key {key} in MuData .{attr} or in .{attr} of any modalities.")
return df[key].to_numpy()

@deprecated(Deprecation("0.3.4"))
def obs_vector(self, key: str, layer: str | None = None) -> np.ndarray:
"""Return an array of values for the requested key of length n_obs.

Expand Down Expand Up @@ -1391,6 +1393,7 @@ def n_var(self) -> int:
# )
return self._var.shape[0]

@deprecated(Deprecation("0.3.4"))
def var_vector(self, key: str, layer: str | None = None) -> np.ndarray:
"""Return an array of values for the requested key of length n_var.

Expand Down Expand Up @@ -1558,22 +1561,27 @@ def uns(self):
# _keys methods to increase compatibility
# with calls requiring those AnnData methods

@deprecated(Deprecation("0.3.4", msg="Use `obs.columns` instead."))
def obs_keys(self) -> list[str]:
"""List keys of observation annotation :attr:`obs`."""
return self._obs.keys().tolist()

@deprecated(Deprecation("0.3.4", msg="Use `var.columns` instead."))
def var_keys(self) -> list[str]:
"""List keys of variable annotation :attr:`var`."""
return self._var.keys().tolist()

@deprecated(Deprecation("0.3.4", msg="Use `obsm.keys()` instead."))
def obsm_keys(self) -> list[str]:
"""List keys of observation annotation :attr:`obsm`."""
return list(self._obsm.keys())

@deprecated(Deprecation("0.3.4", msg="Use `varm.keys()` instead."))
def varm_keys(self) -> list[str]:
"""List keys of variable annotation :attr:`varm`."""
return list(self._varm.keys())

@deprecated(Deprecation("0.3.4", msg="Use `uns.keys()` instead."))
def uns_keys(self) -> list[str]:
"""List keys of unstructured annotation."""
return list(self._uns.keys())
Expand All @@ -1599,6 +1607,7 @@ def axis(self) -> Literal[-1, 0, 1]:
return self._axis

@property
@deprecated(Deprecation("0.3.4", msg="Use `mod.keys()` instead."))
def mod_names(self) -> list[str]:
"""Names of modalities (alias for `list(mdata.mod.keys())`)"""
return list(self._mod.keys())
Expand Down
8 changes: 5 additions & 3 deletions src/mudata/_core/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from __future__ import annotations

from collections import Counter
from collections.abc import Mapping, Sequence
from contextlib import suppress
from typing import Literal, TypeVar
from typing import TYPE_CHECKING, Literal

import numpy as np
import pandas as pd

T = TypeVar("T", pd.Series, pd.DataFrame)
if TYPE_CHECKING:
from collections.abc import Mapping, Sequence


def _make_index_unique(df: pd.DataFrame, force: bool = False) -> pd.DataFrame:
Expand Down
Loading