scverse / squidpy

Spatial Single Cell Analysis in Python
https://squidpy.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
440 stars 82 forks source link

Fix sparse matrix interactions in `sq.gr.utils`. #891

Closed alam-shahul closed 1 month ago

alam-shahul commented 2 months ago

Made to be compatible with new anndata release.

IMPORTANT: Please search among the Pull requests before creating one.

Description

In sq.gr.utils, we change mentions of SparseCSRView and SparseCSCView to SparseCSRMatrixView and SparseCSCMatrixView, respectively. We also update pyproject.toml to use anndata>=0.11.0rc1. I suppose that the latter is still under development, but I feel it will soon be part of the main release.

How has this been tested?

Unfortunately I ran into an error when trying to test this locally:

(squidpy_development) [shahula@lanec1 squidpy]$ tox -e py310-linux -- tests/graph/test_utils.py
.pkg: _optional_hooks> python /work/magroup/shahula/bin/miniconda3/envs/squidpy_development/lib/python3.10/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: get_requires_for_build_editable> python /work/magroup/shahula/bin/miniconda3/envs/squidpy_development/lib/python3.10/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: build_editable> python /work/magroup/shahula/bin/miniconda3/envs/squidpy_development/lib/python3.10/site-packages/pyproject_api/_backend.py True hatchling.build
py310-linux: install_package_deps> python -I -m pip install 'Pillow>=8.0.0' 'aiohttp>=3.8.1' 'anndata>=0.11.0rc1' 'cycler>=0.11.0' 'dask-image>=0.5.0' 'dask[array]>=2021.02.0' 'docrep>=0.3.1' 'fsspec>=2021.11.0' 'leidenalg>=0.8.2' 'matplotlib-sc
alebar>=0.8.0' 'matplotlib>=3.3' 'networkx>=2.6.0' 'numba>=0.56.4' 'numpy>=1.23.0' 'omnipath>=1.0.7' 'pandas>=2.1.0' 'scanpy>=1.9.3' 'scikit-image>=0.20' 'scikit-learn>=0.24.0' 'spatialdata>=0.2.0' 'statsmodels>=0.12.0' 'tifffile!=2022.4.22' 'tq
dm>=4.50.2' 'validators>=0.18.2' 'xarray>=0.16.1' 'zarr>=2.6.1'
py310-linux: install_package> python -I -m pip install --force-reinstall --no-deps /work/magroup/shahula/spatiotemporal_transcriptomics_integration/squidpy/.tox/.tmp/package/2/squidpy-1.6.2.dev1+ge6b5b0c.d20240923-py3-none-any.whl
py310-linux: commands[0]> python -m pytest --cov --cov-append --cov-report=xml --cov-config=/work/magroup/shahula/spatiotemporal_transcriptomics_integration/squidpy/tox.ini --ignore docs/ tests/graph/test_utils.py --test-napari
ImportError while loading conftest '/work/magroup/shahula/spatiotemporal_transcriptomics_integration/squidpy/tests/conftest.py'.
tests/conftest.py:20: in <module>
    import spatialdata as sd
.tox/py310-linux/lib/python3.10/site-packages/spatialdata/__init__.py:54: in <module>
    from spatialdata import dataloader, datasets, models, transformations
.tox/py310-linux/lib/python3.10/site-packages/spatialdata/datasets.py:21: in <module>
    from spatialdata._core.operations.aggregate import aggregate
.tox/py310-linux/lib/python3.10/site-packages/spatialdata/_core/operations/aggregate.py:20: in <module>
    from spatialdata._core.operations._utils import _parse_element
.tox/py310-linux/lib/python3.10/site-packages/spatialdata/_core/operations/_utils.py:8: in <module>
    from spatialdata.models import SpatialElement
.tox/py310-linux/lib/python3.10/site-packages/spatialdata/models/__init__.py:18: in <module>
    from spatialdata.models.models import (
.tox/py310-linux/lib/python3.10/site-packages/spatialdata/models/models.py:20: in <module>
    from multiscale_spatial_image import to_multiscale
.tox/py310-linux/lib/python3.10/site-packages/multiscale_spatial_image/__init__.py:14: in <module>
    from .multiscale_spatial_image import MultiscaleSpatialImage
.tox/py310-linux/lib/python3.10/site-packages/multiscale_spatial_image/multiscale_spatial_image.py:7: in <module>
    from zarr.storage import BaseStore
.tox/py310-linux/lib/python3.10/site-packages/zarr/__init__.py:2: in <module>
    from zarr.codecs import *
.tox/py310-linux/lib/python3.10/site-packages/zarr/codecs.py:2: in <module>
    from numcodecs import *
.tox/py310-linux/lib/python3.10/site-packages/numcodecs/__init__.py:25: in <module>
    from numcodecs.version import version as __version__
E   ModuleNotFoundError: No module named 'numcodecs.version'
py310-linux: exit 4 (10.90 seconds) /work/magroup/shahula/spatiotemporal_transcriptomics_integration/squidpy> python -m pytest --cov --cov-append --cov-report=xml --cov-config=/work/magroup/shahula/spatiotemporal_transcriptomics_integration/squidpy/tox.ini --ignore docs/ tests/graph/test_utils.py --test-napari pid=9214
.pkg: _exit> python /work/magroup/shahula/bin/miniconda3/envs/squidpy_development/lib/python3.10/site-packages/pyproject_api/_backend.py True hatchling.build
  py310-linux: FAIL code 4 (79.67=setup[68.77]+cmd[10.90] seconds)
  evaluation failed :( (80.53 seconds)

but this should be a drop-in fix...

Closes

This closes #890 .

codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 68.68%. Comparing base (4a632d6) to head (70e9bb2). Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
src/squidpy/gr/_utils.py 50.00% 3 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #891 +/- ## ========================================== - Coverage 69.99% 68.68% -1.32% ========================================== Files 39 38 -1 Lines 5532 5572 +40 Branches 1037 1186 +149 ========================================== - Hits 3872 3827 -45 - Misses 1367 1448 +81 - Partials 293 297 +4 ``` | [Files with missing lines](https://app.codecov.io/gh/scverse/squidpy/pull/891?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse) | Coverage Δ | | |---|---|---| | [src/squidpy/gr/\_utils.py](https://app.codecov.io/gh/scverse/squidpy/pull/891?src=pr&el=tree&filepath=src%2Fsquidpy%2Fgr%2F_utils.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse#diff-c3JjL3NxdWlkcHkvZ3IvX3V0aWxzLnB5) | `59.65% <50.00%> (-0.70%)` | :arrow_down: | ... and [10 files with indirect coverage changes](https://app.codecov.io/gh/scverse/squidpy/pull/891/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse)
ilan-gold commented 1 month ago

@timtreis @giovp Can we merge and make a release?

alam-shahul commented 1 month ago

Hi, just wondering if the release/PyPI update will be made soon?