From 9d8cc9fdc4aeeeb97c38622a18128e9af46ef14f Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Mon, 25 Apr 2022 09:34:48 +0200
Subject: [PATCH] Polish

---
 cost_function.py | 10 +++++-----
 segments.py      |  8 +-------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/cost_function.py b/cost_function.py
index 21bc53b7..79771be1 100755
--- a/cost_function.py
+++ b/cost_function.py
@@ -32,7 +32,7 @@ import bisect
 
 def calculate_radii_and_rossby(start, end, inc, segment, e_overestim, handlers,
                                array_d_init):
-    radii = 0 #[m]
+    radii = 0 # in m
     rossby = 0
     days_modifier = 0
 
@@ -112,7 +112,7 @@ print("Number of edges:", g.num_edges())
 print("Internal properties:")
 g.list_properties()
 t1 = time.perf_counter()
-timings.write(f"loading: {t1 - t0} s\n")
+timings.write(f"loading: {t1 - t0:.0f} s\n")
 t0 = t1
 
 g.vp['pos_first'] = g.new_vp('object')
@@ -226,7 +226,7 @@ for n in g.vertices():
         g.vp.last_av_rad[n] = radii
 
 t1 = time.perf_counter()
-timings.write(f"iterating on vertices: {t1 - t0} s\n")
+timings.write(f"iterating on vertices: {t1 - t0:.0f} s\n")
 t0 = t1
 print("Iterating on edges...")
 
@@ -285,11 +285,11 @@ for edge in g.edges():
     g.ep.cost_function[edge] = cf
 
 t1 = time.perf_counter()
-timings.write(f"iterating on edges: {t1 - t0} s\n")
+timings.write(f"iterating on edges: {t1 - t0:.0f} s\n")
 t0 = t1
 print("Saving...")
 g.save('segments_cost_functions.gt')
 print('All done')
 t1 = time.perf_counter()
-timings.write(f"saving: {t1 - t0} s\n")
+timings.write(f"saving: {t1 - t0:.0f} s\n")
 timings.close()
diff --git a/segments.py b/segments.py
index 5d6b6e98..78d2981b 100755
--- a/segments.py
+++ b/segments.py
@@ -13,10 +13,6 @@ import time
 import sys
 import pathlib
 
-##########################
-# load the edgelist file #
-##########################
-
 if len(sys.argv) != 3: sys.exit("Required arguments: input-file output-file")
 
 if pathlib.Path(sys.argv[2]).suffix not in {".gt", ".graphml"}:
@@ -37,9 +33,7 @@ t1 = time.perf_counter()
 print(f'Loading done in {t1 - t0:.0f} s')
 t0 = t1
 
-##############
-# Processing #
-##############
+# Processing:
 
 g.vp['segment'] = g.new_vp('object') # this object will be a list
 print('Collapsing into segments...')
-- 
GitLab