def test_python_simplify_sample_subset(self, ts, nsamples): sub_samples = random.sample(list(ts.samples()), min(nsamples, ts.sample_size)) s = tests.Simplifier(ts, sub_samples) py_small_ts, py_small_map = s.simplify() small_ts, small_map = ts.simplify(samples=sub_samples, map_nodes=True) small_ts.tables.assert_equals(py_small_ts.tables, ignore_provenance=True) self.verify_simplify(ts, small_ts, sub_samples, small_map) self.verify_haplotypes(ts, samples=sub_samples)
def test_python_simplify_all_samples(self, ts): s = tests.Simplifier(ts, ts.samples()) py_full_ts, py_full_map = s.simplify() full_ts, full_map = ts.simplify(ts.samples(), map_nodes=True) assert all(py_full_map == full_map) tsutil.assert_table_collections_equal( full_ts.tables, py_full_ts.tables, ignore_provenance=True )
def test_simplify(self): # check that simplify(big set) -> simplify(subset) equals simplify(subset) seed = 23 random.seed(seed) for ts in self.get_wf_sims(seed=seed): s = tests.Simplifier(ts, ts.samples()) py_full_ts, py_full_map = s.simplify() full_ts, full_map = ts.simplify(ts.samples(), map_nodes=True) self.assertTrue(all(py_full_map == full_map)) self.assertTreeSequencesEqual(full_ts, py_full_ts) for nsamples in [2, 5, 10]: sub_samples = random.sample(ts.samples(), min(nsamples, ts.sample_size)) s = tests.Simplifier(ts, sub_samples) py_small_ts, py_small_map = s.simplify() small_ts, small_map = ts.simplify(samples=sub_samples, map_nodes=True) self.assertTreeSequencesEqual(small_ts, py_small_ts) self.verify_simplify(ts, small_ts, sub_samples, small_map) self.verify_haplotypes(ts, samples=sub_samples)