From 2d1b06c85306d86f42c17b9ac7e62cbb7f104b54 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Sat, 23 Nov 2024 15:35:05 -0800 Subject: [PATCH 1/2] add mock test for SpatialCompare --- tests/test_spatial_compare.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/test_spatial_compare.py b/tests/test_spatial_compare.py index 87922dc..0ebfa09 100644 --- a/tests/test_spatial_compare.py +++ b/tests/test_spatial_compare.py @@ -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"] @@ -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"] \ No newline at end of file + 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) \ No newline at end of file From 40dbb690fb3cab4f81fb2507fbc70f8522d840cc Mon Sep 17 00:00:00 2001 From: Brian Long Date: Sat, 23 Nov 2024 15:36:09 -0800 Subject: [PATCH 2/2] bump --- .github/workflows/test.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b7ba42b --- /dev/null +++ b/.github/workflows/test.yml @@ -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 +