@@ -3223,6 +3223,76 @@ def test_single_binary_tree_keep_roots_mutations(self):
32233223 keep_input_roots = True ,
32243224 )
32253225
3226+ def test_map_mutations_with_and_without_roots (self ):
3227+ nodes_before = """\
3228+ id is_sample time
3229+ 0 1 0
3230+ 1 0 1
3231+ """
3232+ edges_before = """\
3233+ left right parent child
3234+ 0 2 1 0
3235+ """
3236+ sites = """\
3237+ id position ancestral_state
3238+ 0 1.0 0
3239+ """
3240+ mutations_before = """\
3241+ site node derived_state
3242+ 0 0 2
3243+ 0 1 1
3244+ """
3245+ # expected result without keep_input_roots
3246+ nodes_after = """\
3247+ id is_sample time
3248+ 0 1 0
3249+ """
3250+ edges_after = """\
3251+ left right parent child
3252+ """
3253+ mutations_after = """\
3254+ site node derived_state
3255+ 0 0 2
3256+ 0 0 1
3257+ """
3258+ # expected result with keep_input_roots
3259+ nodes_after_keep = nodes_before
3260+ edges_after_keep = """\
3261+ left right parent child
3262+ 0 2 1 0
3263+ """
3264+ mutations_after_keep = """\
3265+ site node derived_state
3266+ 0 0 2
3267+ 0 0 1
3268+ """
3269+ self .verify_simplify (
3270+ samples = [0 ],
3271+ nodes_before = nodes_before ,
3272+ edges_before = edges_before ,
3273+ sites_before = sites ,
3274+ mutations_before = mutations_before ,
3275+ nodes_after = nodes_after ,
3276+ edges_after = edges_after ,
3277+ sites_after = sites ,
3278+ mutations_after = mutations_after ,
3279+ keep_input_roots = False ,
3280+ debug = True
3281+ )
3282+ self .verify_simplify (
3283+ samples = [0 ],
3284+ nodes_before = nodes_before ,
3285+ edges_before = edges_before ,
3286+ sites_before = sites ,
3287+ mutations_before = mutations_before ,
3288+ nodes_after = nodes_after_keep ,
3289+ edges_after = edges_after_keep ,
3290+ sites_after = sites ,
3291+ mutations_after = mutations_after_keep ,
3292+ keep_input_roots = True ,
3293+ debug = True
3294+ )
3295+
32263296 def test_overlapping_edges (self ):
32273297 nodes = """\
32283298 id is_sample time
0 commit comments