|
32 | 32 | import numcodecs |
33 | 33 | import numcodecs.blosc as blosc |
34 | 34 | import zarr |
| 35 | +import tskit |
35 | 36 |
|
36 | 37 | import tsinfer |
37 | 38 | import tsinfer.formats as formats |
@@ -89,7 +90,7 @@ def verify_data_round_trip(self, ts, input_file): |
89 | 90 | self.assertEqual(input_file.num_samples, ts.num_samples) |
90 | 91 | self.assertEqual(input_file.sequence_length, ts.sequence_length) |
91 | 92 | self.assertEqual(input_file.num_sites, ts.num_sites) |
92 | | - self.assertEqual(input_file.sites_genotypes.dtype, np.uint8) |
| 93 | + self.assertEqual(input_file.sites_genotypes.dtype, np.int8) |
93 | 94 | self.assertEqual(input_file.sites_position.dtype, np.float64) |
94 | 95 | # Take copies to avoid decompressing the data repeatedly. |
95 | 96 | genotypes = input_file.sites_genotypes[:] |
@@ -240,14 +241,14 @@ def test_provenance(self): |
240 | 241 |
|
241 | 242 | def test_variant_errors(self): |
242 | 243 | input_file = formats.SampleData(sequence_length=10) |
243 | | - genotypes = np.zeros(2, np.uint8) |
| 244 | + genotypes = np.zeros(2, np.int8) |
244 | 245 | input_file.add_site(0, alleles=["0", "1"], genotypes=genotypes) |
245 | 246 | for bad_position in [-1, 10, 100]: |
246 | 247 | self.assertRaises( |
247 | 248 | ValueError, input_file.add_site, position=bad_position, |
248 | 249 | alleles=["0", "1"], genotypes=genotypes) |
249 | 250 | for bad_genotypes in [[0, 2], [-1, 0], [], [0], [0, 0, 0]]: |
250 | | - genotypes = np.array(bad_genotypes, dtype=np.uint8) |
| 251 | + genotypes = np.array(bad_genotypes, dtype=np.int8) |
251 | 252 | self.assertRaises( |
252 | 253 | ValueError, input_file.add_site, position=1, |
253 | 254 | alleles=["0", "1"], genotypes=genotypes) |
@@ -785,15 +786,15 @@ def get_example_data(self, sample_size, sequence_length, num_ancestors): |
785 | 786 | num_sites = sample_data.num_inference_sites |
786 | 787 | ancestors = [] |
787 | 788 | for j in range(num_ancestors): |
788 | | - haplotype = np.zeros(num_sites, dtype=np.uint8) + tsinfer.UNKNOWN_ALLELE |
| 789 | + haplotype = np.full(num_sites, tskit.MISSING_DATA, dtype=np.int8) |
789 | 790 | start = j |
790 | 791 | end = max(num_sites - j, start + 1) |
791 | 792 | self.assertLess(start, end) |
792 | 793 | haplotype[start: end] = 0 |
793 | 794 | if start + j < end: |
794 | 795 | haplotype[start + j: end] = 1 |
795 | | - self.assertTrue(np.all(haplotype[:start] == tsinfer.UNKNOWN_ALLELE)) |
796 | | - self.assertTrue(np.all(haplotype[end:] == tsinfer.UNKNOWN_ALLELE)) |
| 796 | + self.assertTrue(np.all(haplotype[:start] == tskit.MISSING_DATA)) |
| 797 | + self.assertTrue(np.all(haplotype[end:] == tskit.MISSING_DATA)) |
797 | 798 | focal_sites = np.array([start + k for k in range(j)], dtype=np.int32) |
798 | 799 | focal_sites = focal_sites[focal_sites < end] |
799 | 800 | haplotype[focal_sites] = 1 |
@@ -955,26 +956,26 @@ def test_add_ancestor_errors(self): |
955 | 956 | self.assertRaises( |
956 | 957 | ValueError, ancestor_data.add_ancestor, |
957 | 958 | start=0, end=num_sites, age=1, focal_sites=[], |
958 | | - haplotype=np.zeros(num_sites + 1, dtype=np.uint8)) |
| 959 | + haplotype=np.zeros(num_sites + 1, dtype=np.int8)) |
959 | 960 | # Haplotypes must be < 2 |
960 | 961 | self.assertRaises( |
961 | 962 | ValueError, ancestor_data.add_ancestor, |
962 | 963 | start=0, end=num_sites, age=1, focal_sites=[], |
963 | | - haplotype=np.zeros(num_sites, dtype=np.uint8) + 2) |
| 964 | + haplotype=np.full(num_sites, 2, dtype=np.int8)) |
964 | 965 | # focal sites must be within start:end |
965 | 966 | self.assertRaises( |
966 | 967 | ValueError, ancestor_data.add_ancestor, |
967 | 968 | start=1, end=num_sites, age=1, focal_sites=[0], |
968 | | - haplotype=np.ones(num_sites - 1, dtype=np.uint8)) |
| 969 | + haplotype=np.ones(num_sites - 1, dtype=np.int8)) |
969 | 970 | self.assertRaises( |
970 | 971 | ValueError, ancestor_data.add_ancestor, |
971 | 972 | start=0, end=num_sites - 2, age=1, focal_sites=[num_sites - 1], |
972 | | - haplotype=np.ones(num_sites, dtype=np.uint8)) |
| 973 | + haplotype=np.ones(num_sites, dtype=np.int8)) |
973 | 974 | # focal sites must be set to 1 |
974 | 975 | self.assertRaises( |
975 | 976 | ValueError, ancestor_data.add_ancestor, |
976 | 977 | start=0, end=num_sites, age=1, focal_sites=[0], |
977 | | - haplotype=np.zeros(num_sites, dtype=np.uint8)) |
| 978 | + haplotype=np.zeros(num_sites, dtype=np.int8)) |
978 | 979 |
|
979 | 980 | @unittest.skipIf(sys.platform == "win32", |
980 | 981 | "windows simultaneous file permissions issue") |
|
0 commit comments