Skip to content

Commit cbc8db9

Browse files
committed
Simplify the compatibility layer
1 parent 529c20e commit cbc8db9

1 file changed

Lines changed: 19 additions & 23 deletions

File tree

src/mudata/_core/compat.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,47 @@
1-
from collections.abc import Mapping
1+
from __future__ import annotations
2+
23
from typing import TYPE_CHECKING
34

45
if TYPE_CHECKING:
6+
from collections.abc import Mapping
7+
58
from anndata import AnnData
9+
from anndata._core.raw import Raw
610

711
try:
812
from anndata._core.aligned_mapping import AlignedView, AxisArrays, PairwiseArrays
913
except ImportError:
1014
# anndata < 0.10.9
1115
from anndata._core.aligned_mapping import (
12-
AlignedActualMixin,
16+
AlignedViewMixin as AlignedView,
17+
)
18+
from anndata._core.aligned_mapping import (
19+
AxisArrays as AxisArraysLegacy,
20+
)
21+
from anndata._core.aligned_mapping import (
1322
AxisArraysBase,
14-
PairwiseArraysBase,
1523
)
1624
from anndata._core.aligned_mapping import (
17-
AlignedViewMixin as AlignedView,
25+
PairwiseArrays as PairwiseArraysLegacy,
1826
)
1927

20-
class AxisArrays(AlignedActualMixin, AxisArraysBase):
28+
class AxisArrays(AxisArraysLegacy):
2129
def __init__(
2230
self,
23-
parent: "AnnData",
31+
parent: AnnData | Raw,
2432
axis: int,
2533
store: Mapping | AxisArraysBase | None = None,
2634
):
27-
self._parent = parent
28-
if axis not in {0, 1}:
29-
raise ValueError()
30-
self._axis = axis
31-
self._data = dict()
32-
if store is not None:
33-
self.update(store)
34-
35-
class PairwiseArrays(AlignedActualMixin, PairwiseArraysBase):
35+
super().__init__(parent, axis=axis, vals=store)
36+
37+
class PairwiseArrays(PairwiseArraysLegacy):
3638
def __init__(
3739
self,
38-
parent: "AnnData",
40+
parent: AnnData,
3941
axis: int,
4042
store: Mapping | None = None,
4143
):
42-
self._parent = parent
43-
if axis not in {0, 1}:
44-
raise ValueError()
45-
self._axis = axis
46-
self._data = dict()
47-
if store is not None:
48-
self.update(store)
44+
super().__init__(parent, axis=axis, vals=store)
4945

5046

5147
__all__ = ["AlignedView", "AxisArrays", "PairwiseArrays"]

0 commit comments

Comments
 (0)