BioSTEAMDevelopmentGroup / biosteam

The Biorefinery Simulation and Techno-Economic Analysis Modules; Life Cycle Assessment; Chemical Process Simulation Under Uncertainty
Other
176 stars 35 forks source link

Valve node has no label #185

Closed sarangbhagwat closed 7 months ago

sarangbhagwat commented 7 months ago

Describe the bug Valve units and systems with valve units cannot run diagram().

To Reproduce

import biosteam as bst
import thermosteam as tmo
tmo.settings.set_thermo(['Water', 'Ethanol'])
V101 = bst.Valve('V101')
V101.diagram()

Expected behavior See a valve diagram.

Actual behavior

  File ~\untitled0.py:12
    V101.diagram()

  File ~\biosteam\biosteam\_unit.py:2133 in diagram
    return bst.System(None, units).diagram(

  File ~\biosteam\biosteam\_system.py:2013 in diagram
    return f

  File ~\biosteam\biosteam\_preferences.py:303 in __exit__
    if exception: raise exception

  File ~\biosteam\biosteam\_system.py:1986 in diagram
    f = self._thorough_digraph(graph_attrs)

  File ~\biosteam\biosteam\_system.py:1932 in _thorough_digraph
    return digraph_from_units(self.unit_path, self.streams, **graph_attrs)

  File ~\biosteam\biosteam\digraph\digraph.py:230 in digraph_from_units
    digraph = digraph_from_units_and_connections(units, get_all_connections(streams), auxiliaries, **graph_attrs)

  File ~\biosteam\biosteam\digraph\digraph.py:288 in digraph_from_units_and_connections
    update_digraph_from_units_and_connections(f, units, connections, with_auxiliaries)

  File ~\biosteam\biosteam\digraph\digraph.py:341 in update_digraph_from_units_and_connections
    add_connections(f, connections, get_unit_names(f, units, with_auxiliaries))

  File ~\biosteam\biosteam\digraph\digraph.py:325 in get_unit_names
    label = node['label']

KeyError: 'label'

Version commit a0d0aaa5b425ab945664b34bffe0d274e6ca00e6

Additional context This seems to be because of a temporary fix previously implemented in biosteam._graphics.tailor_valve_node. The simplest resolution seems to be removing the temporary fix. The node's label can remain '' and xlabel can continue serving the purpose of the label as originally desired.