Skip to content
Snippets Groups Projects
Commit 8b773790 authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Use `if` instead of `try`

Preparing for more complex script.
parent ad657b4e
No related branches found
No related tags found
No related merge requests found
......@@ -94,21 +94,20 @@ traj_segm = [] # an element of traj_segm is a trajectory, represented
expanded_traj = [] # an element of expanded_traj is a trajectory,
# represented by a list of instantaneous eddies
try:
if "cost_function" in g.edge_properties:
all_cost = g.get_edges([g.edge_properties.cost_function])
# numpy array with dtype float64
except AttributeError:
# This happens if there are only isolated segments.
print("No cost values in the input file.")
all_cost = np.empty((0, 3))
# Array of indices that sort on cost:
ind_cost = np.argsort(all_cost[:, 2])
# Array of indices that sort on cost:
ind_cost = np.argsort(all_cost[:, 2])
# Loop over edges in ascending order of cost:
for i in ind_cost:
ind_traj = assign_traj_edge(all_cost[i, 0], all_cost[i, 1], traj_prop,
ind_traj, g, traj_segm, expanded_traj)
# Loop over edges in ascending order of cost:
for i in ind_cost:
ind_traj = assign_traj_edge(all_cost[i, 0], all_cost[i, 1], traj_prop,
ind_traj, g, traj_segm, expanded_traj)
else:
# This happens if there are only isolated segments.
print("No cost values in the input file.")
# Create trajectories for isolated segments:
for v in g.vertices():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment