From a0d0be210e9bc1c41bfdb599348a6460f310fea8 Mon Sep 17 00:00:00 2001 From: anushka255 <66816733+anushka255@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:48:44 -0400 Subject: [PATCH] minor update (#1) added pytest as dependency; added init file under test directory; getting rid of glob from test --- environment.yml | 10 +++++----- requirements.txt | 1 + tests/__init__.py | 0 tests/conftest.py | 19 +++++++++---------- 4 files changed, 15 insertions(+), 15 deletions(-) create mode 100644 tests/__init__.py diff --git a/environment.yml b/environment.yml index c5f4291..938dc27 100644 --- a/environment.yml +++ b/environment.yml @@ -1,10 +1,10 @@ name: 'paste' channels: - - defaults + - defaults dependencies: - - python=3.8 - - pip - - pip: - - -r requirements.txt \ No newline at end of file + - python=3.8 + - pip + - pip: + - -r requirements.txt diff --git a/requirements.txt b/requirements.txt index f366f98..564b213 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ numpy scipy scikit-learn>=0.24.0 IPython>=7.18.1 +pytest diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/conftest.py b/tests/conftest.py index cdc9ff5..d6cc0ff 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,24 +1,23 @@ from pathlib import Path - import numpy as np import scanpy as sc -import glob import pytest base_dir = Path(__file__).parent.parent -data_folder = base_dir / "sample_data" +data_dir = base_dir / "sample_data" @pytest.fixture(scope="session") def slices(): - # Returns ann data object relating each slices - slice_files = glob.glob(f"{data_folder}/slice[0-9].csv") - coord_files = glob.glob(f"{data_folder}/slice[0-9]_coor.csv") - slices = [] - for slice, coord in zip(slice_files, coord_files): - _slice = sc.read_csv(Path(slice)) - _slice.obsm["spatial"] = np.genfromtxt(coord, delimiter=",") + for i in range(1, 5): + # File path of slices and respective coordinates + s_fpath = Path(f"{data_dir}/slice{i}.csv") + c_fpath = Path(f"{data_dir}/slice{i}_coor.csv") + + # Create ann data object of each slice and add other properties + _slice = sc.read_csv(s_fpath) + _slice.obsm["spatial"] = np.genfromtxt(c_fpath, delimiter=",") _slice.obsm["weights"] = np.ones((_slice.shape[0],)) / _slice.shape[0] slices.append(_slice)