-
Notifications
You must be signed in to change notification settings - Fork 23
Description
(I've rewritten these functions to solve these issues and I'm working on verifying if they work, before I propose a pull request! However, there are some choices of functionality I've had to make which we can discuss in the pull request)
Hi, on line 543 of flowsheet.py there is a typo which causes a bug with merge_HI_nodes
edge_infos_out["he"].append("{counter}_out")
should be
edge_infos_out["he"].append(f"{counter}_out") (f-string).
If you want, you may fix this bug before my pull request because I think this is an easy fix!
Also, calling split_HI_nodes() and then merge_HI_nodes() causes duplicate tags (because tags are not destroyed when hex are decoupled, but are regenerated when they are merged).
Finally, using "hot_in", "cold_in" etc. as tags kind of works (as stated in line 589):
# (This works for tags of the form hot_in,hot_out,cold_in,cold_out,1_in,1_out, ...)
but when merging nodes back, we'll also end up with duplicate in or out tags, one with "hot" and another with a number.
Example: edge
('expander-1', 'hex-1', {'tags': {'he': ['hot_in'], 'col': []}})
Becomes:
('expander-1', 'hex-1', {'tags': {'he': ['hot_in', '2_in'], 'col': []}})
Finally, if a hex is connected to itself through the same port:
("hex-1", "hex-1", {"tags": {"he": ["1_out", "1_in"], "col": []}})
There is a bug in split_HI_nodes which will generate a hex-1/1 -> hex-1/2 connection instead of a hex-1/1 <-> hex-1/1 one. Also, merge_HI_nodes does not allow merging of hex-1/1 <-> hex-1/1 into hex-1 connected to itself, even though networkx.DiGraph allows for these (however, if we also have ("hex-1", "hex-1", {"tags": {"he": [**"2_out", "2_in"**], "col": []}}) we'll get in trouble without MultiDiGraph, which I'm still working on :))
I suggest adding tests for this type of thing in the future, as the current demonstrations only check for sfiles conversion (which still works).