From 78647f9bfe09c9574e4557d00b3988a4996e493b Mon Sep 17 00:00:00 2001 From: jkobject Date: Wed, 20 May 2026 07:45:31 +0000 Subject: [PATCH] fix: scipy>=1.15 compat + lamindb modules flag - preprocess.additional_postprocess: cast pandas boolean Series to numpy before indexing AnnData.X, since scipy>=1.15 removed implicit relaxed indexing of sparse arrays with pandas Series (reported in #32). - docs/README: replace deprecated 'lamin init --schema bionty' with the current 'lamin init --modules bionty' (lamindb 2.1.x). - bump version to 2.1.3. Refs jkobject/scDataLoader#32. --- README.md | 8 ++++---- docs/index.md | 8 ++++---- docs/notebooks/1_download_and_preprocess.ipynb | 2 +- pyproject.toml | 2 +- scdataloader/preprocess.py | 4 +++- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d69bf7c..53a7fee 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ pip install scdataloader # or pip install scDataLoader[dev] # for dev dependencies -lamin init --storage ./testdb --name test --schema bionty +lamin init --storage ./testdb --name test --modules bionty ``` if you start with lamin and had to do a `lamin init`, you will also need to @@ -107,7 +107,7 @@ pip install -e scDataLoader[dev] ```python # initialize a local lamin database -#! lamin init --storage ./cellxgene --name cellxgene --schema bionty +#! lamin init --storage ./cellxgene --name cellxgene --modules bionty from scdataloader import utils, Preprocessor, DataModule @@ -143,7 +143,7 @@ more ```python # initialize a local lamin database -#! lamin init --storage ./cellxgene --name cellxgene --schema bionty +#! lamin init --storage ./cellxgene --name cellxgene --modules bionty from scdataloader import utils, Preprocessor, SimpleAnnDataset, Collator, DataLoader @@ -203,7 +203,7 @@ scDataLoader as a script (a notebook version is also available in ```python # initialize a local lamin database -#! lamin init --storage ./cellxgene --name cellxgene --schema bionty +#! lamin init --storage ./cellxgene --name cellxgene --modules bionty from scdataloader import utils from scdataloader.preprocess import LaminPreprocessor, additional_postprocess, additional_preprocess diff --git a/docs/index.md b/docs/index.md index d979407..87e9f14 100644 --- a/docs/index.md +++ b/docs/index.md @@ -53,7 +53,7 @@ pip install scdataloader # or pip install scDataLoader[dev] # for dev dependencies -lamin init --storage ./testdb --name test --schema bionty +lamin init --storage ./testdb --name test --modules bionty ``` if you start with lamin and had to do a `lamin init`, you will also need to @@ -97,7 +97,7 @@ pip install -e scDataLoader[dev] ```python # initialize a local lamin database -#! lamin init --storage ./cellxgene --name cellxgene --schema bionty +#! lamin init --storage ./cellxgene --name cellxgene --modules bionty from scdataloader import utils, Preprocessor, DataModule @@ -133,7 +133,7 @@ more ```python # initialize a local lamin database -#! lamin init --storage ./cellxgene --name cellxgene --schema bionty +#! lamin init --storage ./cellxgene --name cellxgene --modules bionty from scdataloader import utils, Preprocessor, SimpleAnnDataset, Collator, DataLoader @@ -193,7 +193,7 @@ scDataLoader as a script (a notebook version is also available in ```python # initialize a local lamin database -#! lamin init --storage ./cellxgene --name cellxgene --schema bionty +#! lamin init --storage ./cellxgene --name cellxgene --modules bionty from scdataloader import utils from scdataloader.preprocess import LaminPreprocessor, additional_postprocess, additional_preprocess diff --git a/docs/notebooks/1_download_and_preprocess.ipynb b/docs/notebooks/1_download_and_preprocess.ipynb index 6691db5..325f973 100644 --- a/docs/notebooks/1_download_and_preprocess.ipynb +++ b/docs/notebooks/1_download_and_preprocess.ipynb @@ -30,7 +30,7 @@ ], "source": [ "# initialize a local lamin database\n", - "# !lamin init --storage ~/scdataloader --schema bionty\n", + "# !lamin init --storage ~/scdataloader --modules bionty\n", "! lamin load scdataloader" ] }, diff --git a/pyproject.toml b/pyproject.toml index 3ad7996..c8e5a07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "scdataloader" -version = "2.1.2" +version = "2.1.3" description = "a dataloader for single cell data in lamindb" authors = [ {name = "jkobject", email = "jkobject@gmail.com"} diff --git a/scdataloader/preprocess.py b/scdataloader/preprocess.py index c1311ef..6cce138 100644 --- a/scdataloader/preprocess.py +++ b/scdataloader/preprocess.py @@ -866,10 +866,12 @@ def additional_postprocess(adata): adata.obs[NEWOBS] = adata.obs[NEWOBS].map(relab) + # scipy >= 1.15 no longer accepts a pandas Series for sparse boolean + # indexing of AnnData.X, so cast the mask to a numpy array. cluster_means = pd.DataFrame( np.array( [ - adata.X[adata.obs[NEWOBS] == i].mean(axis=0) + adata.X[(adata.obs[NEWOBS] == i).to_numpy()].mean(axis=0) for i in adata.obs[NEWOBS].unique() ] )[:, 0, :],