Skip to content

Commit

Permalink
Merge pull request #200 from stompsjo/flow_graph_bugfix
Browse files Browse the repository at this point in the history
[Bugfix] graphs.flow_graph: Keeping columns in dataframe used for defining edges
  • Loading branch information
gonuke authored Jul 16, 2024
2 parents c81155c + ad9a97e commit 2645e8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ v1.6.0

* Converted test suite from nose to pytest (#188)
* Removed some unused imports, mainly pyne (#184)
* `flow_graph` now plots institutions and regions hierarchically as subgraphs (#197)
* `flow_graph` now plots institutions and regions hierarchically as subgraphs (#197, #200)

v1.5.5
====================
Expand Down
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 2645e8f

Please sign in to comment.