Skip to content

Commit

Permalink
Update What's New
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Apr 30, 2024
1 parent 5d8e2b5 commit 76dac63
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ What's New

Discover notable new features and improvements in each release

.. include:: whats_new/v0-7-4.rst
.. include:: whats_new/v0-7-3.rst
.. include:: whats_new/v0-7-2.rst
.. include:: whats_new/v0-7-1.rst
Expand Down
41 changes: 41 additions & 0 deletions docs/whats_new/v0-7-4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
v0.7.4 - Newton's Nature (April, 30, 2024)
++++++++++++++++++++++++++++++++++++++++++

Bug Fixes
#########
- :code:`Component` and :code:`FluidWrapper` objects are now available for the
:code:`load_network` function via the :code:`@component_registry` and
:code:`@wrapper_registry` decorators. E.g. if you are using custom components
you can decorate them with the :code:`@component_registry` and the load a
:code:`Network` with those components without needing to adjust the source
code of the :code:`load_network` function
(`PR #510 <https://github.com/oemof/tespy/pull/510>`__).

.. code-block:: python
>>> from tespy.components.component import component_registry
>>> from tespy.components import Source, Sink, SimpleHeatExchanger
>>> from tespy.connections import Connection
>>> from tespy.networks import Network, load_network
>>> @component_registry
... class MyComponent(SimpleHeatExchanger):
... pass
>>> c = component_registry.items["MyComponent"]("I am a component")
>>> c.label
'I am a component'
>>> nwk = Network()
>>> c1 = Connection(Source("source"), "out1", c, "in1", label="1")
>>> c2 = Connection(c, "out1", Sink("sink"), "in1", label="2")
>>> nwk.add_conns(c1, c2)
>>> nwk.export("exported_nwk")
>>> nwk = load_network("exported_nwk")
>>> nwk.comps.loc["I am a component", "comp_type"]
'MyComponent'
Contributors
############
- Francesco Witte (`@fwitte <https://github.com/fwitte>`__)
- `@jfreissmann <https://github.com/jfreissmann>`__
9 changes: 5 additions & 4 deletions src/tespy/networks/network_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,11 @@ def _construct_components(target_class, data):
for param, param_data in cp_data.items():
container = instances[cp].get_attr(param)
if isinstance(container, dc):
if isinstance(container, dc_cc):
param_data["char_func"] = CharLine(**param_data["char_func"])
elif isinstance(container, dc_cm):
param_data["char_func"] = CharMap(**param_data["char_func"])
if "char_func" in param_data:
if isinstance(container, dc_cc):
param_data["char_func"] = CharLine(**param_data["char_func"])
elif isinstance(container, dc_cm):
param_data["char_func"] = CharMap(**param_data["char_func"])
if isinstance(container, dc_prop):
param_data["val0"] = param_data["val"]
container.set_attr(**param_data)
Expand Down

0 comments on commit 76dac63

Please sign in to comment.