Skip to content

Commit

Permalink
Merge branch 'main' into zarr-sparse-array
Browse files Browse the repository at this point in the history
  • Loading branch information
ilan-gold authored Sep 5, 2023
2 parents 4f7ee76 + fea7561 commit cb1ddcd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/check-pr-milestoned.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ on:
- synchronize

env:
LABELS: ${{ join( github.event.pull_request.labels.*.name, '|' ) }}
LABELS: ${{ join(github.event.pull_request.labels.*.name, '|') }}

jobs:
check-milestone:
name: "Triage: Check Milestone"
runs-on: ubuntu-latest
steps:
- if: github.event.pull_request.milestone == null && contains( env.LABELS, 'no milestone' ) == false
- name: Check if merging isn’t blocked
if: contains(env.LABELS, 'DON’T MERGE')
run: exit 1
- name: Check if a milestone is necessary and exists
if: github.event.pull_request.milestone == null && contains(env.LABELS, 'no milestone') == false
run: exit 1
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ repos:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: "v0.0.286"
rev: "v0.0.287"
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.2
rev: v3.0.3
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
6 changes: 5 additions & 1 deletion anndata/_core/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def __init__(
self._n_obs = adata.n_obs
# construct manually
if adata.isbacked == (X is None):
self._X = X
# Move from GPU to CPU since it's large and not always used
if isinstance(X, (CupyArray, CupySparseMatrix)):
self._X = X.get()
else:
self._X = X
self._var = _gen_dataframe(var, self.X.shape[1], ["var_names"])
self._varm = AxisArrays(self, 1, varm)
elif X is None: # construct from adata
Expand Down
27 changes: 27 additions & 0 deletions anndata/tests/test_gpu.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import pytest
from scipy import sparse

from anndata import AnnData, Raw


@pytest.mark.gpu
Expand All @@ -9,3 +12,27 @@ def test_gpu():
import cupy # This test shouldn't run if cupy isn't installed

cupy.ones(1)


@pytest.mark.gpu
def test_adata_raw_gpu():
from cupyx.scipy import sparse as cupy_sparse
import cupy as cp

adata = AnnData(
X=cupy_sparse.random(500, 50, density=0.01, format="csr", dtype=cp.float32)
)
adata.raw = adata
assert isinstance(adata.raw.X, sparse.csr_matrix)


@pytest.mark.gpu
def test_raw_gpu():
from cupyx.scipy import sparse as cupy_sparse
import cupy as cp

adata = AnnData(
X=cupy_sparse.random(500, 50, density=0.01, format="csr", dtype=cp.float32)
)
araw = Raw(adata)
assert isinstance(araw.X, sparse.csr_matrix)

0 comments on commit cb1ddcd

Please sign in to comment.