Skip to content

Commit

Permalink
bugfix for dataframe used for defining edges in graphs.flow_graph
Browse files Browse the repository at this point in the history
  • Loading branch information
u9f committed Jul 16, 2024
1 parent c81155c commit 81fa0a6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions cymetric/graphs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""A plot generator for Cymetric.
"""

import warnings


try:
from graphviz import Digraph

Expand All @@ -26,8 +23,8 @@ def flow_graph(
stop=None,
):
"""
Generate the dot graph of the transation between facilitiese. Applying times
nuclides selection when required.
Generate the dot graph of the transation between facilitiese.
Applying times nuclides selection when required.
Parameters
----------
Expand All @@ -36,8 +33,8 @@ def flow_graph(
receivers : list of the receiving facility to consider
commodities : list of the commodity exchanged to consider
nucs : list of nuclide to consider
label : label key, used to add label on the arrow connecting facilities (for
commodity use 'com', for mass use 'mass', for both use com,mass)
label : label key, used to add label on the arrow connecting facilities
(for commodity use 'com', for mass use 'mass', for both use com,mass)
start : first timestep to consider, start included
stop : last timestep to consider, stop included
"""
Expand All @@ -50,7 +47,13 @@ def flow_graph(
if stop is not None:
df = df.loc[(df["Time"] <= stop)]

group_end = ["ReceiverPrototype", "SenderPrototype", "Commodity"]
group_end = [
"ReceiverPrototype",
"SenderPrototype",
"Commodity",
"SenderId",
"ReceiverId",
]
group_start = group_end + ["Mass"]
df = df[group_start].groupby(group_end).sum()
df.reset_index(inplace=True)
Expand Down

0 comments on commit 81fa0a6

Please sign in to comment.