Skip to content

Commit 914c193

Browse files
committed
Add additional tskit tests
1 parent 6708eb1 commit 914c193

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
@@ -40,29 +40,54 @@ def test_simple_tree_sequence(self, tmp_path):
4040
tmp_path / "test.trees", zarr_path, ind_nodes, show_progress=False
4141
)
4242
zroot = zarr.open(zarr_path, mode="r")
43-
assert zroot["variant_position"].shape == (3,)
44-
assert list(zroot["variant_position"][:]) == [10, 20, 30]
43+
pos = zroot["variant_position"][:]
44+
assert pos.shape == (3,)
45+
assert pos.dtype == np.int8
46+
assert np.array_equal(pos, [10, 20, 30])
4547

4648
alleles = zroot["variant_allele"][:]
49+
assert alleles.shape == (3, 2)
50+
assert alleles.dtype == "O"
4751
assert np.array_equal(alleles, [["A", "T"], ["C", "G"], ["G", "A"]])
4852

4953
genotypes = zroot["call_genotype"][:]
54+
assert genotypes.shape == (3, 2, 2)
55+
assert genotypes.dtype == np.int8
5056
assert np.array_equal(
5157
genotypes, [[[1, 1], [0, 0]], [[0, 0], [1, 1]], [[1, 0], [0, 0]]]
5258
)
5359

5460
phased = zroot["call_genotype_phased"][:]
61+
assert phased.shape == (3, 2)
62+
assert phased.dtype == np.bool
5563
assert np.all(phased)
5664

5765
contigs = zroot["contig_id"][:]
66+
assert contigs.shape == (1,)
67+
assert contigs.dtype == "O"
5868
assert np.array_equal(contigs, ["1"])
5969

6070
contig = zroot["variant_contig"][:]
71+
assert contig.shape == (3,)
72+
assert contig.dtype == np.int8
6173
assert np.array_equal(contig, [0, 0, 0])
6274

6375
samples = zroot["sample_id"][:]
76+
assert samples.shape == (2,)
77+
assert samples.dtype == "O"
6478
assert np.array_equal(samples, ["tsk_0", "tsk_1"])
6579

80+
assert set(zroot.array_keys()) == {
81+
"variant_position",
82+
"variant_allele",
83+
"call_genotype",
84+
"call_genotype_phased",
85+
"call_genotype_mask",
86+
"contig_id",
87+
"variant_contig",
88+
"sample_id",
89+
}
90+
6691

6792
class TestTskitFormat:
6893
"""Unit tests for TskitFormat without using full conversion."""

0 commit comments

Comments
 (0)