Skip to content

Commit 02f5643

Browse files
committed
use collection ABCs instead of private classes in type hints
1 parent 58d398e commit 02f5643

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

src/mudata/_core/mudata.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import numpy as np
1818
import pandas as pd
1919
from anndata import AnnData
20-
from anndata._core.aligned_mapping import AxisArraysBase, PairwiseArraysView
20+
from anndata._core.aligned_mapping import AxisArraysBase
2121
from anndata._core.views import DataFrameView
2222
from anndata.utils import convert_to_dict
2323

@@ -584,7 +584,7 @@ def _update_attr(
584584

585585
attrm = getattr(self, attr + "m")
586586
attrp = getattr(self, attr + "p")
587-
attrmap = getattr(self, attr + "map")
587+
attrmap = getattr(self, f"_{attr}map")
588588

589589
dfs = [
590590
getattr(a, attr).loc[:, []].assign(**{f"{m}:{rowcol}": np.arange(getattr(a, attr).shape[0])})
@@ -847,7 +847,7 @@ def _update_attr_legacy(
847847

848848
attrm = getattr(self, attr + "m")
849849
attrp = getattr(self, attr + "p")
850-
attrmap = getattr(self, attr + "map")
850+
attrmap = getattr(self, f"_{attr}map")
851851

852852
if join_common:
853853
# If all modalities have a column with the same name, it is not global
@@ -1432,7 +1432,7 @@ def var_names(self, names: Sequence[str]):
14321432
# Multi-dimensional annotations (.obsm and .varm)
14331433

14341434
@property
1435-
def obsm(self) -> MuAxisArrays | MuAxisArraysView:
1435+
def obsm(self) -> MutableMapping[str]:
14361436
"""Multi-dimensional annotation of observations.
14371437
14381438
Stores for each key a two- or higher-dimensional :class:`~numpy.ndarray` or :class:`~pandas.DataFrame` of length :attr:`n_obs`.
@@ -1441,7 +1441,7 @@ def obsm(self) -> MuAxisArrays | MuAxisArraysView:
14411441
return self._obsm
14421442

14431443
@obsm.setter
1444-
def obsm(self, value):
1444+
def obsm(self, value: Mapping[str]):
14451445
obsm = MuAxisArrays(self, axis=0, store=convert_to_dict(value))
14461446
if self.is_view:
14471447
self._init_as_actual(self.copy())
@@ -1452,7 +1452,7 @@ def obsm(self):
14521452
self.obsm = {}
14531453

14541454
@property
1455-
def obsp(self) -> PairwiseArrays | PairwiseArraysView:
1455+
def obsp(self) -> MutableMapping[str]:
14561456
"""Pairwise annotatation of observations.
14571457
14581458
Stores for each key a two- or higher-dimensional :class:`~numpy.ndarray` whose first two dimensions are of liength `n_obs`.
@@ -1461,7 +1461,7 @@ def obsp(self) -> PairwiseArrays | PairwiseArraysView:
14611461
return self._obsp
14621462

14631463
@obsp.setter
1464-
def obsp(self, value):
1464+
def obsp(self, value: Mapping[str]):
14651465
obsp = PairwiseArrays(self, axis=0, store=convert_to_dict(value))
14661466
if self.is_view:
14671467
self._init_as_actual(self.copy())
@@ -1472,17 +1472,17 @@ def obsp(self):
14721472
self.obsp = {}
14731473

14741474
@property
1475-
def obsmap(self) -> PairwiseArrays | PairwiseArraysView:
1475+
def obsmap(self) -> Mapping[str]:
14761476
"""Mapping of observation indices in the object to indices in individual modalities.
14771477
14781478
Contains an entry for each modality. Each entry is an :class:`~numpy.ndarray` with shape `(n_obs, 1)`. Each element
14791479
in the array contains the numerical index of the observation in the respective modality corresponding to the :class:`MuData`
14801480
observation in that position. The index is 1-based, 0 indicates that the observation is missing in the modality.
14811481
"""
1482-
return self._obsmap
1482+
return MappingProxyType(self._obsmap)
14831483

14841484
@property
1485-
def varm(self) -> MuAxisArrays | MuAxisArraysView:
1485+
def varm(self) -> MutableMapping[str]:
14861486
"""Multi-dimensional annotation of variables.
14871487
14881488
Stores for each key a two- or higher-dimensional :class:`~numpy.ndarray` or :class:`~pandas.DataFrame` of length :attr:`n_vars`.
@@ -1491,7 +1491,7 @@ def varm(self) -> MuAxisArrays | MuAxisArraysView:
14911491
return self._varm
14921492

14931493
@varm.setter
1494-
def varm(self, value):
1494+
def varm(self, value: Mapping[str]):
14951495
varm = MuAxisArrays(self, axis=1, store=convert_to_dict(value))
14961496
if self.is_view:
14971497
self._init_as_actual(self.copy())
@@ -1502,7 +1502,7 @@ def varm(self):
15021502
self.varm = {}
15031503

15041504
@property
1505-
def varp(self) -> PairwiseArrays | PairwiseArraysView:
1505+
def varp(self) -> MutableMapping[str]:
15061506
"""Pairwise annotatation of variables.
15071507
15081508
Stores for each key a two- or higher-dimensional :class:`~numpy.ndarray` whose first two dimensions are of liength `n_obs`.
@@ -1511,7 +1511,7 @@ def varp(self) -> PairwiseArrays | PairwiseArraysView:
15111511
return self._varp
15121512

15131513
@varp.setter
1514-
def varp(self, value):
1514+
def varp(self, value: Mapping[str]):
15151515
varp = PairwiseArrays(self, axis=0, store=convert_to_dict(value))
15161516
if self.is_view:
15171517
self._init_as_actual(self.copy())
@@ -1522,14 +1522,14 @@ def varp(self):
15221522
self.varp = {}
15231523

15241524
@property
1525-
def varmap(self) -> PairwiseArrays | PairwiseArraysView:
1525+
def varmap(self) -> Mapping[str]:
15261526
"""Mapping of feature indices in the object to indices in individual modalities.
15271527
15281528
Contains an entry for each modality. Each entry is an :class:`~numpy.ndarray` with shape `(n_obs, 1)`. Each element
15291529
in the array contains the numerical index of the feature in the respective modality corresponding to the :class:`MuData`
15301530
feature in that position. The index is 1-based, 0 indicates that the feature is missing in the modality.
15311531
"""
1532-
return self._varmap
1532+
return MappingProxyType(self._varmap)
15331533

15341534
# Unstructured annotations
15351535

0 commit comments

Comments
 (0)