-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
136 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
schedule: | ||
- cron: "0 5 1,15 * *" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
shell: bash -e {0} # -e to fail on error | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
python: "3.9" | ||
- os: ubuntu-latest | ||
python: "3.11" | ||
- os: ubuntu-latest | ||
python: "3.11" | ||
pip-flags: "--pre" | ||
name: PRE-RELEASE DEPENDENCIES | ||
|
||
name: ${{ matrix.name }} Python ${{ matrix.python }} | ||
|
||
env: | ||
OS: ${{ matrix.os }} | ||
PYTHON: ${{ matrix.python }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
cache: "pip" | ||
cache-dependency-path: "**/pyproject.toml" | ||
|
||
- name: Install test dependencies | ||
run: | | ||
python -m pip install --upgrade pip wheel | ||
- name: Install dependencies | ||
run: | | ||
pip install ${{ matrix.pip-flags }} ".[dev,test]" | ||
- name: Test | ||
env: | ||
MPLBACKEND: agg | ||
PLATFORM: ${{ matrix.os }} | ||
DISPLAY: :42 | ||
run: | | ||
coverage run -m pytest -v --color=yes | ||
- name: Report coverage | ||
run: | | ||
coverage report | ||
- name: Upload coverage | ||
uses: codecov/codecov-action@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -389,6 +389,7 @@ def main(): | |
num_workers=args.num_workers, | ||
show=False, | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pytest | ||
import anndata as ad | ||
import numpy as np | ||
import pandas as pd | ||
|
||
np.random.seed(42) | ||
|
||
@pytest.fixture(scope='session') | ||
def adata_test(n_obs=16, n_vars=32, n_categories=3): | ||
""" | ||
Creates a virtual AnnData object with random binary data for testing. | ||
Parameters: | ||
- n_obs (int): Number of observations (cells) | ||
- n_vars (int): Number of variables (genes) | ||
- n_categories (int): Number of categories for the categorical annotation | ||
Returns: | ||
- An AnnData object populated with binary data and annotations. | ||
""" | ||
# Generate random binary data | ||
X = np.random.randint(0, 2, size=(n_obs, n_vars)) # Random binary matrix (0s and 1s) | ||
|
||
# Generate observation names and variable names | ||
obs_names = [f"Cell_{i}" for i in range(n_obs)] | ||
var_names = [f"Gene_{j}" for j in range(n_vars)] | ||
|
||
# Create observation (cell) metadata | ||
obs = pd.DataFrame({ | ||
'condition': np.random.choice([f"Condition_{i}" for i in range(1, n_categories + 1)], n_obs), | ||
'batch': np.random.choice([i for i in range(1, n_categories + 1)], n_obs) | ||
}, index=obs_names) | ||
|
||
# Create variable (gene) metadata | ||
var = pd.DataFrame({ | ||
'Gene_ID': var_names | ||
}, index=var_names) | ||
|
||
# Create AnnData object | ||
adata = ad.AnnData(X=X, obs=obs, var=var) | ||
adata.obs['batch'] = adata.obs['batch'].astype('category') | ||
|
||
return adata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters