Skip to content

Commit 587a29e

Browse files
benjefferyjeromekelleher
authored andcommitted
Add additional tskit tests
1 parent d2d4119 commit 587a29e

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

tests/test_ts.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,54 @@ def test_simple_tree_sequence(self, tmp_path):
4545
show_progress=False,
4646
)
4747
zroot = zarr.open(zarr_path, mode="r")
48-
assert zroot["variant_position"].shape == (3,)
49-
assert list(zroot["variant_position"][:]) == [10, 20, 30]
48+
pos = zroot["variant_position"][:]
49+
assert pos.shape == (3,)
50+
assert pos.dtype == np.int8
51+
assert np.array_equal(pos, [10, 20, 30])
5052

5153
alleles = zroot["variant_allele"][:]
54+
assert alleles.shape == (3, 2)
55+
assert alleles.dtype == "O"
5256
assert np.array_equal(alleles, [["A", "T"], ["C", "G"], ["G", "A"]])
5357

5458
genotypes = zroot["call_genotype"][:]
59+
assert genotypes.shape == (3, 2, 2)
60+
assert genotypes.dtype == np.int8
5561
assert np.array_equal(
5662
genotypes, [[[1, 1], [0, 0]], [[0, 0], [1, 1]], [[1, 0], [0, 0]]]
5763
)
5864

5965
phased = zroot["call_genotype_phased"][:]
66+
assert phased.shape == (3, 2)
67+
assert phased.dtype == np.bool
6068
assert np.all(phased)
6169

6270
contigs = zroot["contig_id"][:]
71+
assert contigs.shape == (1,)
72+
assert contigs.dtype == "O"
6373
assert np.array_equal(contigs, ["1"])
6474

6575
contig = zroot["variant_contig"][:]
76+
assert contig.shape == (3,)
77+
assert contig.dtype == np.int8
6678
assert np.array_equal(contig, [0, 0, 0])
6779

6880
samples = zroot["sample_id"][:]
81+
assert samples.shape == (2,)
82+
assert samples.dtype == "O"
6983
assert np.array_equal(samples, ["tsk_0", "tsk_1"])
7084

85+
assert set(zroot.array_keys()) == {
86+
"variant_position",
87+
"variant_allele",
88+
"call_genotype",
89+
"call_genotype_phased",
90+
"call_genotype_mask",
91+
"contig_id",
92+
"variant_contig",
93+
"sample_id",
94+
}
95+
7196

7297
class TestTskitFormat:
7398
"""Unit tests for TskitFormat without using full conversion."""

0 commit comments

Comments
 (0)