12 (3, 2, (1, 1, 1), (0, 0, 0)),
16 dimensions, target_subtree, parent_coords, mixed_parent_coords
19 Stage II ("Bottom-Up Propagation") invariant test in 2D and 3D.
21 If all existing children of a parent belong to the same subtree, then after
22 Stage II the parent has to be assigned to that subtree as well.
25 tree =
RegularGridGenerator(name=f
"pytest-tree-{dimensions}d", max_level=2, dimensions=dimensions)
31 assert tree._tree_arrays[parent_level][parent_coords] == (1, 0)
34 ranges = [range(3 * coord, 3 * coord + 3)
for coord
in parent_coords]
35 for child_coords
in itertools.product(*ranges):
36 tree._tree_arrays[child_level][child_coords] = (1, target_subtree)
39 assert tree._tree_arrays[parent_level][mixed_parent_coords] == (1, 0)
43 mixed_child_base = tuple(3 * coord
for coord
in mixed_parent_coords)
44 first_child = mixed_child_base
45 second_child = mixed_child_base[:-1] + (mixed_child_base[-1] + 1,)
46 third_child = mixed_child_base[:-1] + (mixed_child_base[-1] + 2,)
48 tree._tree_arrays[child_level][first_child] = (1, target_subtree)
49 tree._tree_arrays[child_level][second_child] = (1, target_subtree)
50 tree._tree_arrays[child_level][third_child] = (1, 0)
53 split_strategy.propagate_bottom_up(tree)
56 assert tree._tree_arrays[parent_level][parent_coords] == (1, target_subtree)
59 assert tree._tree_arrays[parent_level][mixed_parent_coords] == (1, 0)