Beispiel #1
0
def net_in(request):
    if request.param == 1:
        net = create_test_network()
        net.line_geodata.loc[0, "coords"] = [(1.1, 2.2), (3.3, 4.4)]
        net.line_geodata.loc[11, "coords"] = [(5.5, 5.5), (6.6, 6.6),
                                              (7.7, 7.7)]
        return net
Beispiel #2
0
def test_excel():
    net_in = create_test_network()
    net_in.line_geodata.loc[0, "coords"] = [(1.1, 2.2), (3.3, 4.4)]
    net_in.line_geodata.loc[1, "coords"] = [(5.5, 5.5), (6.6, 6.6), (7.7, 7.7)]
    pp.to_excel(net_in, "testfile.xlsx")
    net_out = pp.from_excel("testfile.xlsx")
    assert_net_equal(net_in, net_out)
    os.remove('testfile.xlsx')
Beispiel #3
0
def test_json():
    net_in = create_test_network()
    net_in.line_geodata.loc[0, "coords"] = [(1.1, 2.2), (3.3, 4.4)]
    net_in.line_geodata.loc[1, "coords"] = [(5.5, 5.5), (6.6, 6.6), (7.7, 7.7)]
    pp.to_json(net_in, "testfile.json")
    net_out = pp.from_json("testfile.json")
    assert_net_equal(net_in, net_out, reindex=True)
    os.remove('testfile.json')
Beispiel #4
0
def test_restore_all_dtypes():
    net = create_test_network()
    pp.runpp(net)
    net['res_test'] = pd.DataFrame(columns=['test'], data=[1, 2, 3])
    net['test'] = pd.DataFrame(columns=['test'], data=[1, 2, 3])
    net.line['test'] = 123
    net.res_line['test'] = 123
    net.bus['test'] = 123
    net.res_bus['test'] = 123
    net.res_load['test'] = 123
    dtdf = collect_all_dtypes_df(net)
    restore_all_dtypes(net, dtdf)
Beispiel #5
0
def test_to_json_dtypes(tempdir):
    filename = os.path.join(tempdir, "testfile.json")
    net = create_test_network()
    pp.runpp(net)
    net['res_test'] = pd.DataFrame(columns=['test'], data=[1, 2, 3])
    net['test'] = pd.DataFrame(columns=['test'], data=[1, 2, 3])
    net.line['test'] = 123
    net.res_line['test'] = 123
    net.bus['test'] = 123
    net.res_bus['test'] = 123
    net.res_load['test'] = 123
    pp.to_json(net, filename)
    net1 = pp.from_json(filename)
Beispiel #6
0
def test_to_json_dtypes(tmp_path):
    filename = os.path.abspath(str(tmp_path)) + "testfile.json"
    net = create_test_network()
    pp.runpp(net)
    net['res_test'] = pd.DataFrame(columns=['test'], data=[1, 2, 3])
    net['test'] = pd.DataFrame(columns=['test'], data=[1, 2, 3])
    net.line['test'] = 123
    net.res_line['test'] = 123
    net.bus['test'] = 123
    net.res_bus['test'] = 123
    net.res_load['test'] = 123
    pp.to_json(net, filename)
    net1 = pp.from_json(filename)
    assert_net_equal(net, net1)
Beispiel #7
0
def test_html(tmp_path):
    net = create_test_network()
    filename = os.path.abspath(str(tmp_path)) + "testfile.html"
    pandapower.plotting.to_html(net, filename)
def test_create_generic_coordinates_nx():
    net = create_test_network()
    net.bus_geodata.drop(net.bus_geodata.index, inplace=True)
    create_generic_coordinates(net, library="networkx")
    assert len(net.bus_geodata) == len(net.bus)
Beispiel #9
0
def test_pickle():
    net_in = create_test_network()
    pp.to_pickle(net_in, "testfile.p")
    net_out = pp.from_pickle("testfile.p")
    assert_net_equal(net_in, net_out)
    os.remove('testfile.p')