Skip to content

Commit

Permalink
getting rid of glob
Browse files Browse the repository at this point in the history
  • Loading branch information
anushka255 committed Aug 6, 2024
1 parent baf6d20 commit 1bdd567
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
from pathlib import Path
import re

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")

slices = []
for slice in slice_files:
# Get coordinates for the current slice
coord = slice.replace(".csv", "_coor.csv")
_slice = sc.read_csv(Path(slice))
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")

_slice.obsm["spatial"] = np.genfromtxt(coord, delimiter=",")
# 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)

Expand Down

0 comments on commit 1bdd567

Please sign in to comment.