def test_pickle(tmp_path): """ Checks if a network saved and reloaded as a pickle file is identical. :return: :rtype: """ net = load_net() filename = os.path.abspath(str(tmp_path)) + "test_net_1.p" # save test network pandapipes.to_pickle(net, filename) # load test network net2 = pandapipes.from_pickle(filename) # check if saved and loaded versions are identical assert pandapipes.nets_equal( net, net2), "Error in comparison after saving to Pickle."
def test_json_string(): """ Checks if a network saved and reloaded as a json file is identical. :return: :rtype: """ net = load_net() # save test network json_string = pandapipes.to_json(net) # load test network net2 = pandapipes.from_json_string(json_string) # check if saved and loaded versions are identical assert_frame_equal(net.pipe_geodata, net2.pipe_geodata) del net.pipe_geodata del net2.pipe_geodata assert pandapipes.nets_equal(net, net2), \ "Error in comparison after saving to JSON string."
def test_json(tmp_path): """ Checks if a network saved and reloaded as a json file is identical. :return: :rtype: """ net = load_net() filename = os.path.abspath(str(tmp_path)) + "test_net_1.json" # save test network pandapipes.to_json(net, filename) # load test network net2 = pandapipes.from_json(filename) # check if saved and loaded versions are identical assert_frame_equal(net.pipe_geodata, net2.pipe_geodata) del net.pipe_geodata del net2.pipe_geodata assert pandapipes.nets_equal( net, net2), "Error in comparison after saving to JSON."