Skip to content

Backport PR #3667 on branch 1.11.x ((fix): axis_nnz explicitly drops axis with dask) #3674

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/3667.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure `axis_nnz` calculates its chunk size/shape correctly with `dask` {smaller}`I Gold`
3 changes: 1 addition & 2 deletions src/scanpy/_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,7 @@ def _(X: DaskArray, axis: Literal[0, 1]) -> DaskArray:
partial(axis_nnz, axis=axis),
dtype=np.int64,
meta=np.array([], dtype=np.int64),
drop_axis=0,
chunks=len(X.to_delayed()) * (X.chunksize[int(not axis)],),
drop_axis=axis,
)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_qc_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def adata() -> AnnData:

def prepare_adata(adata: AnnData) -> AnnData:
if isinstance(adata.X, DaskArray):
adata.X = adata.X.rechunk((100, -1))
adata.X = adata.X.rechunk((10, -1))
adata.var["mito"] = np.concatenate(
(np.ones(100, dtype=bool), np.zeros(900, dtype=bool))
)
Expand Down
Loading