def test_disconnected_elements(test_net, diag_params, diag_errors, report_methods): net = copy.deepcopy(test_net) check_function = 'disconnected_elements' diag_params = copy.deepcopy(diag_params) report_methods = copy.deepcopy(report_methods) net.switch.closed.loc[37, 38] = False pp.drop_trafos(net, [1]) check_result = pp.disconnected_elements(net) if check_result: diag_results = {check_function: check_result} else: diag_results = {} expected_disconnect = [{ 'buses': [33, 36, 37, 38, 39, 40, 41, 42, 43, 44], 'lines': [6, 7, 8, 9, 11, 12, 13], 'loads': [2, 5, 6, 7, 8, 9, 10, 11, 12], 'sgens': [1, 2, 3, 4], 'switches': [ 37, 38, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61 ], 'trafos3w': [0] }, { 'buses': [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56], 'lines': [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], 'loads': [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], 'sgens': [5, 6, 7, 8, 9, 10], 'switches': [ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83 ] }] for area, expected_area in zip(diag_results[check_function], expected_disconnect): assert area == expected_area for bool_value in [True, False]: diag_report = DiagnosticReports(net, diag_results, diag_errors, diag_params, compact_report=bool_value) report_check = None try: eval(report_methods[check_function]) report_check = True except: report_check = False assert report_check
def test_disconnected_elements(test_net): net = copy.deepcopy(test_net) net.switch.closed.loc[37, 38] = False pp.drop_trafos(net, [1]) assert pp.disconnected_elements(net) == \ [{'buses': [33, 36, 37, 38, 39, 40, 41, 42, 43, 44], 'lines': [6, 7, 8, 9, 11, 12, 13], 'loads': [2, 5, 6, 7, 8, 9, 10, 11, 12], 'sgens': [1, 2, 3, 4], 'switches': [37, 38, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61], 'trafos3w': [0]}, {'buses': [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56], 'lines': [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], 'loads': [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], 'sgens': [5, 6, 7, 8, 9, 10], 'switches': [62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83]}]