Skip to content

Commit

Permalink
Merge pull request #238 from Deltares/237-multi-link-redundancy-gener…
Browse files Browse the repository at this point in the history
…ates-no-result

chore: concat multi-link redundancy analysis modified
  • Loading branch information
sahand-asgarpour authored Nov 15, 2023
2 parents de4f1af + 9ee5f86 commit c621c55
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions ra2ce/analyses/indirect/analyses_indirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,31 +344,26 @@ def multi_link_redundancy(self, graph: dict, analysis: AnalysisSectionIndirect):
# save alternative route nodes
alt_nodes = nx.dijkstra_path(graph, u, v)

# append to calculation dataframe
df_calculated = df_calculated.append(
{
"u": u,
"v": v,
"rfid": str(edata["rfid"]),
"alt_dist": alt_dist,
"alt_nodes": alt_nodes,
"connected": 1,
},
ignore_index=True,
)
# append to calculation dataframe. Lists from values to be consistent with the else operation
df_calculated = pd.concat([df_calculated, pd.DataFrame({
"u": [u],
"v": [v],
"rfid": [str(edata["rfid"])],
"alt_dist": [alt_dist],
"alt_nodes": [alt_nodes],
"connected": [1],
})], ignore_index=True)
else:
# append to calculation dataframe
df_calculated = df_calculated.append(
{
"u": u,
"v": v,
"rfid": str(edata["rfid"]),
"alt_dist": np.NaN,
"alt_nodes": np.NaN,
"connected": 0,
},
ignore_index=True,
)
# append to calculation dataframe. Lists from values, otherwise cannot find any index for the newly
# created DataFrame.
df_calculated = pd.concat([df_calculated, pd.DataFrame({
"u": [u],
"v": [v],
"rfid": [str(edata["rfid"])],
"alt_dist": [np.NaN],
"alt_nodes": [np.NaN],
"connected": [0],
})], ignore_index=True)

# Merge the dataframes
gdf = gdf.merge(df_calculated, how="left", on=["u", "v", "rfid"])
Expand Down

0 comments on commit c621c55

Please sign in to comment.