Skip to content

Commit

Permalink
Adapted tests to the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kc611 committed Jun 29, 2023
1 parent dae773c commit 0ea0e6c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 47 deletions.
4 changes: 3 additions & 1 deletion numba_rvsdg/tests/test_fig3.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ def make_flow():


def test_fig3():
# Run this function to print YAML for the given function
f = make_flow()
f.restructure()
f = f.restructure()
print(f.scfg.to_yaml())


if __name__ == "__main__":
Expand Down
11 changes: 4 additions & 7 deletions numba_rvsdg/tests/test_scfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_yaml_conversion(self):
'3': ['4']
'4': []
backedges:
regions:""",
""",
# Case # 2: Cyclic graph, no back edges
"""
blocks:
Expand All @@ -59,7 +59,7 @@ def test_yaml_conversion(self):
'4': []
'5': ['3', '4']
backedges:
regions:""",
""",
# Case # 3: Graph with backedges
"""
blocks:
Expand All @@ -81,7 +81,7 @@ def test_yaml_conversion(self):
'4': ['2', '3']
backedges:
'4': ['2']
regions:""",
""",
]

for case in cases:
Expand All @@ -108,7 +108,6 @@ def test_dict_conversion(self):
"4": [],
},
"backedges": {},
"regions": {},
},
# Case # 2: Cyclic graph, no back edges
{
Expand All @@ -129,7 +128,6 @@ def test_dict_conversion(self):
"5": ["3", "4"],
},
"backedges": {},
"regions": {},
},
# Case # 3: Graph with backedges
{
Expand All @@ -148,7 +146,6 @@ def test_dict_conversion(self):
"4": ["2", "3"],
},
"backedges": {"4": ["2"]},
"regions": {},
},
]

Expand Down Expand Up @@ -177,7 +174,7 @@ def test_scfg_iter(self):
'0': ['1']
'1': []
backedges:
regions:"""
"""
)
received = list(scfg)
self.assertEqual(expected, received)
Expand Down
49 changes: 10 additions & 39 deletions numba_rvsdg/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_linear(self):
'0': ['1']
'1': []
backedges:
regions:"""
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
blocks:
Expand All @@ -34,7 +34,7 @@ def test_linear(self):
'1': []
'2': ['1']
backedges:
regions:"""
"""
expected_scfg, _ = SCFG.from_yaml(expected)
new_name = original_scfg.name_gen.new_block_name(block_names.BASIC)
original_scfg.insert_block(
Expand All @@ -56,7 +56,6 @@ def test_dual_predecessor(self):
'1': ['2']
'2': []
backedges:
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
Expand All @@ -75,7 +74,6 @@ def test_dual_predecessor(self):
'2': []
'3': ['2']
backedges:
regions:
"""
expected_scfg, expected_block_dict = SCFG.from_yaml(expected)
new_name = original_scfg.name_gen.new_block_name(block_names.BASIC)
Expand Down Expand Up @@ -108,7 +106,6 @@ def test_dual_successor(self):
'1': []
'2': []
backedges:
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
Expand All @@ -127,7 +124,6 @@ def test_dual_successor(self):
'2': []
'3': ['1', '2']
backedges:
regions:
"""
expected_scfg, _ = SCFG.from_yaml(expected)
original_scfg.insert_block(
Expand Down Expand Up @@ -158,7 +154,6 @@ def test_dual_predecessor_and_dual_successor(self):
'3': []
'4': []
backedges:
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
Expand All @@ -183,7 +178,6 @@ def test_dual_predecessor_and_dual_successor(self):
'4': []
'5': ['3', '4']
backedges:
regions:
"""
expected_scfg, _ = SCFG.from_yaml(expected)
original_scfg.insert_block(
Expand Down Expand Up @@ -214,7 +208,7 @@ def test_dual_predecessor_and_dual_successor_with_additional_arcs(self):
'3': ['0']
'4': []
backedges:
regions:"""
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
blocks:
Expand All @@ -238,7 +232,6 @@ def test_dual_predecessor_and_dual_successor_with_additional_arcs(self):
'4': []
'5': ['3', '4']
backedges:
regions:
"""
expected_scfg, expected_block_dict = SCFG.from_yaml(expected)
original_scfg.insert_block(
Expand Down Expand Up @@ -272,7 +265,6 @@ def test_two_returns(self):
'1': []
'2': []
backedges:
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
Expand All @@ -291,7 +283,6 @@ def test_two_returns(self):
'2': ['3']
'3': []
backedges:
regions:
"""
expected_scfg, _ = SCFG.from_yaml(expected)
original_scfg.join_returns()
Expand All @@ -310,7 +301,6 @@ def test_join_tails_and_exits_case_00(self):
'0': ['1']
'1': []
backedges:
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
Expand All @@ -323,7 +313,6 @@ def test_join_tails_and_exits_case_00(self):
'0': ['1']
'1': []
backedges:
regions:
"""
expected_scfg, _ = SCFG.from_yaml(expected)

Expand Down Expand Up @@ -354,7 +343,6 @@ def test_join_tails_and_exits_case_01(self):
'2': ['3']
'3': []
backedges:
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
Expand All @@ -376,7 +364,6 @@ def test_join_tails_and_exits_case_01(self):
'3': []
'4': ['1', '2']
backedges:
regions:
"""
expected_scfg, _ = SCFG.from_yaml(expected)

Expand Down Expand Up @@ -410,7 +397,6 @@ def test_join_tails_and_exits_case_02_01(self):
'2': ['3']
'3': []
backedges:
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
Expand All @@ -432,7 +418,6 @@ def test_join_tails_and_exits_case_02_01(self):
'3': []
'4': ['3']
backedges:
regions:
"""
expected_scfg, _ = SCFG.from_yaml(expected)

Expand Down Expand Up @@ -466,7 +451,6 @@ def test_join_tails_and_exits_case_02_02(self):
'2': ['1', '3']
'3': []
backedges:
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
Expand All @@ -488,7 +472,6 @@ def test_join_tails_and_exits_case_02_02(self):
'3': []
'4': ['3']
backedges:
regions:
"""
expected_scfg, _ = SCFG.from_yaml(expected)

Expand Down Expand Up @@ -528,7 +511,6 @@ def test_join_tails_and_exits_case_03_01(self):
'4': ['5']
'5': []
backedges:
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
Expand Down Expand Up @@ -559,7 +541,6 @@ def test_join_tails_and_exits_case_03_01(self):
'6': ['7']
'7': ['3', '4']
backedges:
regions:
"""
expected_scfg, _ = SCFG.from_yaml(expected)

Expand Down Expand Up @@ -601,7 +582,6 @@ def test_join_tails_and_exits_case_03_02(self):
'4': ['5']
'5': []
backedges:
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected = """
Expand Down Expand Up @@ -632,7 +612,6 @@ def test_join_tails_and_exits_case_03_02(self):
'6': ['7']
'7': ['3', '4']
backedges:
regions:
"""
expected_scfg, _ = SCFG.from_yaml(expected)
tails = (block_dict["1"], block_dict["2"])
Expand Down Expand Up @@ -667,7 +646,6 @@ def test_no_op_mono(self):
'1': ['1', '2']
'2': []
backedges:
regions:
"""
expected = """
blocks:
Expand All @@ -683,7 +661,7 @@ def test_no_op_mono(self):
'2': []
backedges:
'1': ['1']
regions:"""
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected_scfg, _ = SCFG.from_yaml(expected)
loop_restructure_helper(original_scfg, set({block_dict["1"]}))
Expand All @@ -707,7 +685,6 @@ def test_no_op(self):
'2': ['1', '3']
'3': []
backedges:
regions:
"""
expected = """
blocks:
Expand All @@ -726,7 +703,6 @@ def test_no_op(self):
'3': []
backedges:
'2': ['1']
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected_scfg, _ = SCFG.from_yaml(expected)
Expand Down Expand Up @@ -756,7 +732,6 @@ def test_backedge_not_exiting(self):
'2': ['1']
'3': []
backedges:
regions:
"""
expected = """
blocks:
Expand Down Expand Up @@ -784,7 +759,6 @@ def test_backedge_not_exiting(self):
'6': ['4']
backedges:
'4': ['1']
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected_scfg, _ = SCFG.from_yaml(expected)
Expand All @@ -810,8 +784,6 @@ def test_multi_back_edge_with_backedge_from_header(self):
'2': ['1', '3']
'3': []
backedges:
regions:
"""
expected = """
blocks:
Expand Down Expand Up @@ -842,7 +814,6 @@ def test_multi_back_edge_with_backedge_from_header(self):
'7': ['4']
backedges:
'4': ['1']
regions:
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected_scfg, _ = SCFG.from_yaml(expected)
Expand Down Expand Up @@ -876,7 +847,7 @@ def test_double_exit(self):
'3': ['1', '4']
'4': []
backedges:
regions:"""
"""
expected = """
blocks:
'0':
Expand Down Expand Up @@ -909,7 +880,7 @@ def test_double_exit(self):
'8': ['5']
backedges:
'5': ['1']
regions:"""
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected_scfg, _ = SCFG.from_yaml(expected)
loop_restructure_helper(
Expand Down Expand Up @@ -943,7 +914,7 @@ def test_double_header(self):
'4': ['1']
'5': []
backedges:
regions:"""
"""
expected = """
blocks:
'0':
Expand Down Expand Up @@ -988,7 +959,7 @@ def test_double_header(self):
'12': ['9']
backedges:
'9': ['6']
regions:"""
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected_scfg, _ = SCFG.from_yaml(expected)
loop_restructure_helper(
Expand Down Expand Up @@ -1039,7 +1010,7 @@ def test_double_header_double_exiting(self):
'6': ['7']
'7': []
backedges:
regions:"""
"""
expected = """
blocks:
'0':
Expand Down Expand Up @@ -1096,7 +1067,7 @@ def test_double_header_double_exiting(self):
'16': ['11']
backedges:
'11': ['8']
regions:"""
"""
original_scfg, block_dict = SCFG.from_yaml(original)
expected_scfg, _ = SCFG.from_yaml(expected)
loop_restructure_helper(
Expand Down

0 comments on commit 0ea0e6c

Please sign in to comment.