Esempio n. 1
0
def test_switch_configuration(test_net, diag_params, report_methods):
    net = copy.deepcopy(test_net)
    check_function = 'wrong_switch_configuration'
    diag_params = copy.deepcopy(diag_params)
    report_methods = copy.deepcopy(report_methods)
    net.switch.closed.at[0] = 0
    net.switch.closed.at[2] = 0
    check_result = pp.wrong_switch_configuration(net)
    if check_result:
        diag_results = {check_function: check_result}
    else:
        diag_results = {}
    assert diag_results[check_function] == True
    for bool_value in [True, False]:
        diag_report = DiagnosticReports(net, diag_results, 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

    net.switch.closed.at[0] = 1
    net.switch.closed.at[2] = 1
    net.switch.closed = 0
    # this will raise the warning "Matrix is exactly singular" -> ignore
    warnings.simplefilter("ignore")
    check_result = pp.wrong_switch_configuration(net)
    if check_result:
        diag_results = {check_function: check_result}
    else:
        diag_results = {}
    assert diag_results[check_function] == True
    for bool_value in [True, False]:
        diag_report = DiagnosticReports(net, diag_results, 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
    net.switch.closed = 1
    net.load.p_kw.at[4] *= 1000
    check_result = pp.wrong_switch_configuration(net)
    if check_result:
        diag_results = {check_function: check_result}
    else:
        diag_results = {}
    assert diag_results[check_function] == 'uncertain'
    for bool_value in [True, False]:
        diag_report = DiagnosticReports(net, diag_results, 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
Esempio n. 2
0
def test_switch_configuration(test_net, diag_params, diag_errors,
                              report_methods):
    net = copy.deepcopy(test_net)
    check_function = 'wrong_switch_configuration'
    check_result = pp.wrong_switch_configuration(net)
    diag_results = {check_function: check_result}
    assert diag_results[check_function] == None
    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

    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

    net = copy.deepcopy(test_net)
    net.switch.closed = 1
    net.load.p_mw.at[4] *= 1000
    check_result = pp.wrong_switch_configuration(net)
    diag_results = {check_function: check_result}
    assert diag_results[check_function] == False
    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
Esempio n. 3
0
def test_switch_configuration(test_net):
    net = copy.deepcopy(test_net)
    net.switch.closed.at[0] = 0
    net.switch.closed.at[2] = 0
    assert pp.wrong_switch_configuration(net) == True
    net.switch.closed.at[0] = 1
    net.switch.closed.at[2] = 1
    net.switch.closed = 0
    assert pp.wrong_switch_configuration(net) == True
    net.switch.closed = 1
    net.load.p_kw.at[4] *= 1000
    assert pp.wrong_switch_configuration(net) == 'uncertain'