Skip to content

Commit 746d85d

Browse files
author
Natalie
committed
Fix: Add compatibility with anndata >= 0.10
The 'read' function was deprecated in anndata 0.8 and removed in 0.10.0. This commit adds a compatibility wrapper that uses read_h5ad as a fallback when the read function is not available, ensuring compatibility with both old and new versions of anndata. Fixes ImportError: cannot import name 'read' from 'anndata' This issue was blocking spateo-release and other downstream packages from working with anndata >= 0.10.
1 parent 9f82563 commit 746d85d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

dynamo/data_io.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from anndata import (
88
AnnData,
9-
read,
109
read_csv,
1110
read_excel,
1211
read_h5ad,
@@ -17,6 +16,15 @@
1716
read_umi_tools,
1817
read_zarr,
1918
)
19+
20+
# Compatibility with anndata >= 0.10
21+
# The 'read' function was deprecated and removed in anndata 0.10.0
22+
# Use read_h5ad as a fallback for backward compatibility
23+
try:
24+
from anndata import read
25+
except ImportError:
26+
# anndata >= 0.10 removed 'read', use 'read_h5ad' instead
27+
from anndata import read_h5ad as read
2028
from tqdm import tqdm
2129

2230
from .dynamo_logger import main_info

0 commit comments

Comments
 (0)