Skip to content
Draft
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
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@ maintainers = [
authors = [
{ name = "Danila Bredikhin" },
]
requires-python = ">=3.10"
requires-python = ">=3.12"
classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Scientific/Engineering :: Bio-Informatics",
]
dynamic = [ "version" ]
dependencies = [
"anndata>=0.10.8",
"anndata>=0.11",
"h5py",
"numpy",
"pandas>=1.4",
Expand Down Expand Up @@ -78,7 +76,7 @@ envs.docs.scripts.open = "python -m webbrowser -t docs/_build/html/index.html"
envs.docs.scripts.clean = "git clean -fdX -- {args:docs}"
envs.hatch-test.dependency-groups = [ "dev", "test" ]
envs.hatch-test.matrix = [
{ deps = [ "stable" ], python = [ "3.11", "3.14" ] },
{ deps = [ "stable" ], python = [ "3.12", "3.14" ] },
{ deps = [ "pre" ], python = [ "3.14" ] }
]
# If the matrix variable `deps` is set to "pre",
Expand Down
29 changes: 0 additions & 29 deletions src/mudata/_core/compat.py

This file was deleted.

40 changes: 6 additions & 34 deletions src/mudata/_core/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
from anndata import AnnData
from anndata._io.h5ad import _read_raw
from anndata._io.h5ad import read_dataframe as read_h5ad_dataframe
from anndata._io.specs.registry import read_elem, write_elem
from anndata._io.zarr import _read_legacy_raw
from anndata._io.zarr import read_dataframe as read_zarr_dataframe
from anndata._io.zarr import write_zarr as anndata_write_zarr
from anndata.compat import _read_attr
from anndata.io import read_elem, write_elem
from anndata.io import read_zarr as anndata_read_zarr
from anndata.io import write_zarr as anndata_write_zarr
from scipy import sparse

from .config import OPTIONS
Expand Down Expand Up @@ -197,7 +197,7 @@ def write_zarr(
if adata.raw is not None:
adata.strings_to_categoricals(adata.raw.var)

if write_data or not adata.isbacked:
if write_data:
if chunks is not None and not isinstance(adata.X, sparse.spmatrix):
write_elem(group, "X", adata.X, dataset_kwargs=dict(chunks=chunks, **kwargs))
else:
Expand Down Expand Up @@ -479,23 +479,19 @@ def read_zarr(store: str | PathLike | MutableMapping | zarr.Group | zarr.abc.sto
"""
import zarr

if isinstance(store, Path):
store = str(store)

f = zarr.open(store, mode="r")
d = {}
if "mod" not in f.keys():
return ad.read_zarr(store)

manager = MuDataFileManager()
for k in f.keys():
if k in {"obs", "var"}:
d[k] = read_zarr_dataframe(f[k])
if k == "mod":
mods = {}
gmods = f[k]
for m in gmods.keys():
mods[m] = _read_zarr_mod(gmods[m], manager)
mods[m] = anndata_read_zarr(gmods[m])

mod_order = None
if "mod-order" in gmods.attrs:
Expand All @@ -508,35 +504,11 @@ def read_zarr(store: str | PathLike | MutableMapping | zarr.Group | zarr.abc.sto
d[k] = read_elem(f[k])

mu = MuData._init_from_dict_(**d)
mu.file = manager
mu.file = MuDataFileManager()

return mu


def _read_zarr_mod(g: zarr.Group, manager: MuDataFileManager = None, backed: bool = False) -> dict:
d = {}

for k in g.keys():
if k in ("obs", "var"):
d[k] = read_zarr_dataframe(g[k])
elif k == "X":
X = g["X"]
if not backed:
d["X"] = read_elem(X)
elif k != "raw":
d[k] = read_elem(g[k])
ad = AnnData(**d)
if manager is not None:
ad.file = AnnDataFileManager(ad, Path(g.name).name, manager)

raw = _read_legacy_raw(
g, d.get("raw"), read_zarr_dataframe, read_elem, attrs=("var", "varm") if backed else ("var", "varm", "X")
)
if raw:
ad._raw = ad.Raw(ad, **raw)
return ad


def _read_h5mu_mod(g: h5py.Group, manager: MuDataFileManager = None, backed: bool = False) -> dict:
d = {}

Expand Down
3 changes: 1 addition & 2 deletions src/mudata/_core/mudata.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
import numpy as np
import pandas as pd
from anndata import AnnData
from anndata._core.aligned_mapping import AxisArraysBase
from anndata._core.aligned_mapping import AlignedView, AxisArrays, AxisArraysBase, PairwiseArrays
from anndata._core.views import DataFrameView
from anndata.utils import convert_to_dict

from .compat import AlignedView, AxisArrays, PairwiseArrays
from .config import OPTIONS
from .file_backing import MuDataFileManager
from .repr import MUDATA_CSS, block_matrix, details_block_table
Expand Down
6 changes: 3 additions & 3 deletions tests/test_pull_push.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Callable
from typing import Literal, TypeAlias
from typing import Literal

import numpy as np
import pandas as pd
Expand All @@ -8,8 +8,8 @@

from mudata import MuData, set_options

Axis: TypeAlias = Literal[0, 1]
AxisAttr: TypeAlias = Literal["obs", "var"]
type Axis = Literal[0, 1]
type AxisAttr = Literal["obs", "var"]


@pytest.fixture(params=(0, 1))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_update.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Mapping, Sequence
from functools import reduce
from typing import Literal, TypeAlias
from typing import Literal

import numpy as np
import pandas as pd
Expand All @@ -10,7 +10,7 @@

from mudata import MuData, set_options

Axis: TypeAlias = Literal[0, 1]
type Axis = Literal[0, 1]


@pytest.fixture
Expand Down
Loading