From a0c7083f515714fce66c24e5cc7862791e2a6f73 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Tue, 22 Oct 2024 17:49:57 +0200 Subject: [PATCH] fix torch import --- docs/conf.py | 3 ++- src/anndata/experimental/pytorch/_annloader.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index fc8a414ea..985fc3e3c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -73,9 +73,10 @@ # Generate the API documentation when building autosummary_generate = True autodoc_member_order = "bysource" +autodoc_mock_imports = ["torch"] +# autodoc_default_flags = ['members'] issues_github_path = "scverse/anndata" rtd_links_prefix = PurePosixPath("src") -# autodoc_default_flags = ['members'] napoleon_google_docstring = False napoleon_numpy_docstring = True napoleon_include_init_with_doc = False diff --git a/src/anndata/experimental/pytorch/_annloader.py b/src/anndata/experimental/pytorch/_annloader.py index 0e98bb065..ddc5e825f 100644 --- a/src/anndata/experimental/pytorch/_annloader.py +++ b/src/anndata/experimental/pytorch/_annloader.py @@ -22,11 +22,12 @@ if TYPE_CHECKING: from collections.abc import Callable, Generator, Sequence - from typing import TypeAlias + from typing import TypeAlias, Union from scipy.sparse import spmatrix - Array: TypeAlias = torch.Tensor | np.ndarray | spmatrix + # need to use Union because of autodoc_mock_imports + Array: TypeAlias = Union[torch.Tensor, np.ndarray, spmatrix] # noqa: UP007 # Custom sampler to get proper batches instead of joined separate indices