Skip to content

Add Array API support via array-api-compat#4179

Draft
amalia-k510 wants to merge 2 commits into
scverse:mainfrom
amalia-k510:array-api-compat-integration
Draft

Add Array API support via array-api-compat#4179
amalia-k510 wants to merge 2 commits into
scverse:mainfrom
amalia-k510:array-api-compat-integration

Conversation

@amalia-k510

Copy link
Copy Markdown
Contributor

This adds Array API support to scanpy's preprocessing pipeline, where I am planning to use JAX as the test case. The goal is for someone to put a JAX array into adata.X and run the usual pipeline without the array getting silently pulled to CPU partway through. It builds on the recent fast-array-utils work, which means a lot of the heavy lifting (sums, means, variances) already works across backends.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 48.31461% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.43%. Comparing base (d96d91d) to head (790ddde).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/scanpy/_utils/__init__.py 19.04% 17 Missing ⚠️
src/scanpy/preprocessing/_scale.py 53.57% 13 Missing ⚠️
src/scanpy/preprocessing/_simple.py 28.57% 5 Missing ⚠️
src/scanpy/metrics/_common.py 25.00% 3 Missing ⚠️
src/scanpy/preprocessing/_highly_variable_genes.py 57.14% 3 Missing ⚠️
src/scanpy/_compat.py 84.61% 2 Missing ⚠️
src/scanpy/neighbors/__init__.py 66.66% 1 Missing ⚠️
src/scanpy/preprocessing/_normalization.py 66.66% 1 Missing ⚠️
src/scanpy/tools/_rank_genes_groups.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main    #4179       +/-   ##
=========================================
+ Coverage      0   79.43%   +79.43%     
=========================================
  Files         0      120      +120     
  Lines         0    12871    +12871     
=========================================
+ Hits          0    10224    +10224     
- Misses        0     2647     +2647     
Flag Coverage Δ
hatch-test.low-vers 78.68% <48.31%> (?)
hatch-test.pre 79.30% <48.31%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scanpy/neighbors/__init__.py 81.93% <66.66%> (ø)
src/scanpy/preprocessing/_normalization.py 93.58% <66.66%> (ø)
src/scanpy/tools/_rank_genes_groups.py 93.11% <66.66%> (ø)
src/scanpy/_compat.py 85.48% <84.61%> (ø)
src/scanpy/metrics/_common.py 91.13% <25.00%> (ø)
src/scanpy/preprocessing/_highly_variable_genes.py 94.13% <57.14%> (ø)
src/scanpy/preprocessing/_simple.py 89.70% <28.57%> (ø)
src/scanpy/preprocessing/_scale.py 80.00% <53.57%> (ø)
src/scanpy/_utils/__init__.py 72.74% <19.04%> (ø)

... and 111 files with indirect coverage changes

@flying-sheep flying-sheep self-requested a review June 25, 2026 14:58

@flying-sheep flying-sheep left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK, please remember the comments from the fast-array-utils PR, e.g. we agreed to handle singledispatch functions like this: https://github.com/scverse/fast-array-utils/blob/febaf245ecd6da849c2331638219f649935d5a21/src/fast_array_utils/stats/_power.py#L38-L39

We also need tests. There’s MAP_ARRAY_TYPES which should gain an entry, which will make many many tests run with the type you add. We can discuss how to best exclude certain tests, for starters you can just add it and make some of the tests fail – that’ll show you where things aren’t working yet (and might or might not be fixed in this PR)

Please also add a release note (hatch run towncrier:create 4179.feat.md)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants