Skip to content

Commit d086fe3

Browse files
Add tests for dataset
1 parent eeadfe4 commit d086fe3

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
run: |
104104
# We are careful to pull in the minimum dependencies here
105105
# and only operate on files stored in the repo
106-
python -m pytest -c /dev/null -p no:sc2ts_fixtures tests/test_api.py
106+
python -m pytest -v -c /dev/null -p no:sc2ts_fixtures tests/test_api.py
107107
108108
packaging:
109109
name: Packaging tests

tests/data/v0.1_dataset_ex.vcz.zip

856 KB
Binary file not shown.

tests/test_api.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,39 @@
55

66

77
@pytest.fixture
8-
def fx_v1_ex():
8+
def fx_ts_v1():
99
return tszip.load("tests/data/v0.1_output_ex.ts.tsz")
1010

1111

12-
class TestBasics:
12+
@pytest.fixture
13+
def fx_ds_v1():
14+
return sc2ts.Dataset("tests/data/v0.1_dataset_ex.vcz.zip")
15+
16+
17+
class TestStatFuncs:
1318

14-
def test_top_level_md(self, fx_v1_ex):
15-
ts = fx_v1_ex
19+
def test_top_level_md(self, fx_ts_v1):
20+
ts = fx_ts_v1
1621
assert ts.metadata == {"time_zero_date": "2020-02-15"}
1722

18-
def test_node_data(self, fx_v1_ex):
19-
ts = fx_v1_ex
23+
def test_node_data(self, fx_ts_v1):
24+
ts = fx_ts_v1
2025
df = sc2ts.node_data(ts)
2126
assert df.shape[0] == ts.num_nodes
2227

23-
def test_mutation_data(self, fx_v1_ex):
24-
ts = fx_v1_ex
28+
def test_mutation_data(self, fx_ts_v1):
29+
ts = fx_ts_v1
2530
df = sc2ts.mutation_data(ts)
2631
assert df.shape[0] == ts.num_mutations
32+
33+
34+
class TestDataset:
35+
36+
def test_basics(self, fx_ds_v1):
37+
ds = fx_ds_v1
38+
G = ds["call_genotype"][:].squeeze()
39+
pos = ds["variant_position"][:]
40+
assert G.shape == (29903, 55)
41+
assert pos.shape == (29903,)
42+
assert pos[0] == 1
43+
assert pos[-1] == 29903

0 commit comments

Comments
 (0)