Skip to content

Replace spmatrix with _CSMatrix as appropriate - #3431

Merged
flying-sheep merged 17 commits into
mainfrom
pa/spmatrix-types
Jan 16, 2025
Merged

flying-sheep merged 17 commits into
mainfrom
pa/spmatrix-types

Conversation

@flying-sheep

@flying-sheep flying-sheep commented Jan 10, 2025 •

Copy link
Copy Markdown
Member
  • Closes #
  • Tests included or not required because:
  • Release notes not necessary because: The only user-facing change is some subtly typing fixes

Preparation for sparray support: make sure spmatrix is only used where it makes sense.

I checked every single instance of spmatrix and either tested that coo_matrix also works or replaced it with _CSMatrix = csr_matrix | csc_matrix.

TODO after this PR:

  1. replace spmatrix with _SpBase = sparray | spmatrix and _CSMatrix with _CSBase = cs{cr}_matrix | cs{cr}_array and test
  2. figure out bsr_array

@codecov

codecov Bot commented Jan 10, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 95.32710% with 5 lines in your changes missing coverage. Please review.

Project coverage is 75.43%. Comparing base (fa38823) to head (15bdc02).
Report is 55 commits behind head on main.

Files with missing lines Patch % Lines
src/scanpy/metrics/_common.py 85.71% 2 Missing ⚠️
src/scanpy/preprocessing/_utils.py 71.42% 2 Missing ⚠️
src/scanpy/tools/_utils.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3431      +/-   ##
==========================================
+ Coverage   75.36%   75.43%   +0.06%     
==========================================
  Files         112      112              
  Lines       13219    13235      +16     
==========================================
+ Hits         9963     9984      +21     
+ Misses       3256     3251       -5     
Files with missing lines Coverage Δ
src/scanpy/_utils/__init__.py 74.71% <100.00%> (+0.24%) ⬆️
src/scanpy/_utils/compute/is_constant.py 77.50% <100.00%> (-0.55%) ⬇️
src/scanpy/external/tl/_harmony_timeseries.py 33.33% <ø> (ø)
src/scanpy/external/tl/_palantir.py 32.43% <ø> (ø)
src/scanpy/get/_aggregated.py 92.15% <100.00%> (+0.05%) ⬆️
src/scanpy/get/get.py 91.46% <100.00%> (ø)
src/scanpy/metrics/_gearys_c.py 59.25% <100.00%> (+2.46%) ⬆️
src/scanpy/metrics/_morans_i.py 66.17% <100.00%> (+2.94%) ⬆️
src/scanpy/neighbors/_types.py 100.00% <100.00%> (ø)
...preprocessing/_deprecated/highly_variable_genes.py 93.47% <ø> (ø)
... and 18 more

... and 1 file with indirect coverage changes

@flying-sheep
flying-sheep marked this pull request as ready for review January 10, 2025 14:51

@ilan-gold ilan-gold left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, about the plan:

replace spmatrix with _SpBase = sparray | spmatrix and _CSMatrix with _CSBase = cs{cr}_matrix | cs{cr}_array and test

I am not sure this will go so smoothly because of differing APIs and version compatibility. It was something of a nightmare in AnnData...

Comment thread src/scanpy/metrics/_common.py Resolved
Comment thread src/scanpy/preprocessing/_qc.py Resolved
Comment thread src/scanpy/tools/_utils.py Resolved
@flying-sheep
flying-sheep merged commit 05ab694 into main Jan 16, 2025
@flying-sheep
flying-sheep deleted the pa/spmatrix-types branch January 16, 2025 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants