Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anndata 0.11 and scipy 0.15 fail to load backed sparse anndata object #1811

Closed
1 of 3 tasks
ori-kron-wis opened this issue Jan 6, 2025 · 2 comments
Closed
1 of 3 tasks
Labels

Comments

@ori-kron-wis
Copy link

ori-kron-wis commented Jan 6, 2025

Please make sure these conditions are met

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of anndata.
  • (optional) I have confirmed this bug exists on the master branch of anndata.

Report

scipy updated to 0.15.0 recently, and as a result, we have a test that fails now:

example:

Code:

from scipy.sparse import csr_matrix #scipy 1.15.0
import anndata  as ad #anndata 1.11.1
import numpy as np
import os

counts = csr_matrix(np.random.poisson(1, size=(100, 2000)), dtype=np.float32)
adata = ad.AnnData(counts)
path = os.path.join(".", "test_data2.h5ad")
adata.write_h5ad(path)
adata = ad.read_h5ad(path, backed="r") #also r+ fails
adata.X[:100] #fail

Traceback:

Traceback (most recent call last):
  File "<input>", line 11, in <module>
  File "/opt/miniconda3/envs/scvi/lib/python3.12/site-packages/anndata/_core/sparse_dataset.py", line 431, in __getitem__
    sub = self.to_memory()[row_sp_matrix_validated, col_sp_matrix_validated]
          ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/scvi/lib/python3.12/site-packages/scipy/sparse/_index.py", line 30, in __getitem__
    index, new_shape = self._validate_indices(key)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/scvi/lib/python3.12/site-packages/scipy/sparse/_index.py", line 274, in _validate_indices
    idx = self._asindices(idx, N)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/scvi/lib/python3.12/site-packages/scipy/sparse/_index.py", line 316, in _asindices
    max_indx = x.max()
               ^^^^^^^
  File "/opt/miniconda3/envs/scvi/lib/python3.12/site-packages/numpy/_core/_methods.py", line 44, in _amax
    return umr_maximum(a, axis, None, out, keepdims, initial, where)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>=' not supported between instances of 'int' and 'NoneType'

This is used to work with scipy 0.14.1

Versions

anndata 1.11.1
scipy 1.15.0
@ilan-gold
Copy link
Contributor

I believe this was addressed by #1806

@ori-kron-wis
Copy link
Author

installing from main branch solves the issue. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants