Best Python code snippet using molecule_python
testsuite.py
Source:testsuite.py
...43 g = create_G()44 mst = get_mst(g)45 g.add_edge(10, 1, weight="10")46 print(find_edge(g, 10, mst))47def test_prune():48 mst = get_mst(create_G())49 prune(mst)50def test_partition_graph():51 g = create_G()52 print(partition_graph(g))53def test_choose_max_cut_edge():54 g = create_G()55 l, r = partition_graph(g)56 print(maximum_edge_across_cut(g, l, r))57def test_max_edge():58 g = create_G()59 print(get_max_edge(g))60def test_construct_domsetSPT():61 g = create_G()62 print(construct_domsetSPT(g))63def test_domset_approx():64 g = create_G()65 print(domset_approx(g))66def test_last():67 g = create_G()68 print(find_last(g, alpha = 2))69def test_distance():70 g = create_G()71 print(get_distance(g, 1, 6))72def test_spt():73 g = create_G()74 print(get_spt(g))75def test_mst_parents():76 g = create_G()77 print(get_mst_parents(get_mst(g)))78def test_get_children():79 g = create_G()80 mst_parents = get_mst_parents(get_mst(g))81 print(get_children(mst_parents, 1))82 print(get_children(mst_parents, 2))83 print(get_children(mst_parents, 3))84def test_prune():85 g = create_G()86 mst_g = get_mst(g)87 tree = prune(g, mst_g)88 print(average_pairwise_distance_fast(tree))89def test_repeated_prune():90 g = create_G()91 mst_g = get_mst(g)92 tree = repeated_pruning(g, mst_g)93 print(average_pairwise_distance_fast(tree))94# create_G()95# test_get_rand_node()96# test_get_edges()97# test_choose_random_edge()98# test_get_edge_weight()99# test_move_MST()100# test_find_edge()101# test_prune()102# test_partition_graph()103# test_choose_max_cut_edge()104# test_max_edge()105# test_construct_domsetSPT()106# test_domset_approx()107# test_better_domset()108# test_last()109# test_spt()110# test_distance()111# test_mst_parents()112# test_get_children()113test_prune()114# Can only perform one iteration ...
solution.py
Source:solution.py
...24 return prune(tree.right)25 tree.left = prune(tree.left) 26 tree.right = prune(tree.right) 27 return tree28def test_prune():29 # For example, given the following tree:30 # 31 # 032 # / \33 # 1 234 # / \35 # 3 436 # \ / \37 # 5 6 738 # You should convert it to:39 # 40 # 041 # / \42 # 5 443 # / \44 # 6 745 example = \46 Tree(0,47 Tree(1,48 Tree(3, None, Tree(5)),49 None50 ),51 Tree(2,52 None,53 Tree(4, Tree(6), Tree(7))54 )55 )56 print("before:", example)57 print("after:", prune(example))58if __name__ == "__main__":...
test_prune.py
Source:test_prune.py
...13import metapype.model.metapype_io as metapype_io14import metapype.eml.validate as validate15import tests16logger = daiquiri.getLogger(__name__)17def test_prune():18 if "TEST_DATA" in os.environ:19 test_data = os.environ["TEST_DATA"]20 else:21 test_data = tests.test_data_path22 with open(f"{test_data}/eml.xml", "r") as f:23 xml = "".join(f.readlines())24 eml = metapype_io.from_xml(xml)25 pruned = validate.prune(eml, strict=True)26 for node in pruned:27 print(f"pruned: {node[0].name} - {node[1]}")28 errs = []29 validate.tree(eml, errs)30 for err in errs:31 print(err)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!