Skip to content
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

add mock test for SpatialCompare #13

Merged
merged 2 commits into from
Nov 24, 2024
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
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test

on: [ pull_request]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
lfs: true
- name: Git LFS Pull
run: |
git lfs pull
- name: Install dependencies
run: |
pip install '.[test]'
- name: Run tests
run: |
pytest -rP

15 changes: 12 additions & 3 deletions tests/test_spatial_compare.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from spatial_compare import SpatialCompare, get_column_ordering
import pandas as pd
import anndata as ad
import pathlib

SC_DIR = pathlib.Path().absolute()
print(SC_DIR)

XENIUM_STEM = "xenium.h5ad"
DATA_STEMS = ["CJ_BG_mini1.h5ad", "CJ_BG_mini2.h5ad", "CJ_BG_mini3.h5ad", "CJ_BG_mini4.h5ad"]

TEST_DIR = SC_DIR.joinpath("tests").joinpath("data")
XENIUM_DIR = TEST_DIR.joinpath(XENIUM_STEM)

TEST_ANNDATAS = [ad.read_h5ad(TEST_DIR.joinpath(DATA_STEM)) for DATA_STEM in DATA_STEMS]

TEST_DF_RECORDS = [dict(a=1, b=0.5, c=0.1), dict(a=.5, b=.8, c=.9), dict(a=0.1, b=1., c=0.1)]
TEST_DF = pd.DataFrame.from_records(TEST_DF_RECORDS)
TEST_DF.index = ["a", "b", "c"]
Expand All @@ -16,4 +20,9 @@
def test_get_column_ordering():
ordered_columns = get_column_ordering(TEST_DF, ordered_rows=["a", "b", "c"])
print(ordered_columns)
assert ordered_columns == ["a", "c", "b"]
assert ordered_columns == ["a", "c", "b"]

def test_SpatialCompare():
# mock up test
sc = SpatialCompare(TEST_ANNDATAS[0], TEST_ANNDATAS[1])
assert all(sc.ad_0[0].obs.columns == sc.ad_1[1].obs.columns)
Loading