From ed1d57eebe3dea8dfe9afa5e08e35576f92d642b Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Thu, 14 Apr 2022 22:23:45 +0200 Subject: [PATCH] Choose output file name on the command line Motivation: being able to choose a different output format at run-time. We use the graphml format for the automated test, because graphml is a text format, so we can compare the results of two runs. --- Tests/tests.json | 5 ++++- segments.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Tests/tests.json b/Tests/tests.json index 91ff205a..f8c6e04b 100644 --- a/Tests/tests.json +++ b/Tests/tests.json @@ -6,6 +6,9 @@ { "title": "Segments", "command": - ["$src_dir/segments.py", "$tests_old_dir/EGr2nd15md4/edgelist.csv"] + [ + "$src_dir/segments.py", "$tests_old_dir/EGr2nd15md4/edgelist.csv", + "segments.graphml" + ] } ] diff --git a/segments.py b/segments.py index a37fa39c..9b98808e 100755 --- a/segments.py +++ b/segments.py @@ -14,7 +14,7 @@ import sys # load the edgelist file # ########################## -if len(sys.argv) != 2: sys.exit("Required argument: edgelist-file") +if len(sys.argv) != 3: sys.exit("Required arguments: input-file output-file") t0 = time.perf_counter() print('Loading edgelist file...') g = graph_tool.load_graph_from_csv(sys.argv[1], @@ -77,7 +77,7 @@ t1 = time.perf_counter() print(f"Done deleting in {t1 - t0:.0f} s") t0 = t1 print('Saving graph...') -g.save('segmented.gt') +g.save(sys.argv[2]) t1 = time.perf_counter() print(f'Done saving in {t1 - t0:.0f} s.') print("Everything is cool.") -- GitLab