Repository: oemof/oemof-network

Issue:
Node subclasses are useless
All subclasses to Node (Bus, Component, Sink, Source, and Transformer) do not implement any additional functionality. I think, we can delete them.

Comments:

Patch:
diff --git a/src/oemof/network/network/nodes.py b/src/oemof/network/network/nodes.py
index bc1e1e7..3cb72fa 100644
--- a/src/oemof/network/network/nodes.py
+++ b/src/oemof/network/network/nodes.py
@@ -11,6 +11,8 @@ SPDX-FileCopyrightText: Patrik Schönfeldt <patrik.schoenfeldt@dlr.de>
 SPDX-License-Identifier: MIT
 """
 
+import warnings
+
 from .edge import Edge
 from .entity import Entity
 
@@ -24,9 +26,18 @@ class Node(Entity):
     inputs: list or dict, optional
         Either a list of this nodes' input nodes or a dictionary mapping input
         nodes to corresponding inflows (i.e. input values).
+        List will be converted to dictionary with values set to None.
     outputs: list or dict, optional
         Either a list of this nodes' output nodes or a dictionary mapping
         output nodes to corresponding outflows (i.e. output values).
+        List will be converted to dictionary with values set to None.
+
+    Attributes
+    ----------
+    inputs: dict
+        A dictionary mapping input nodes to corresponding inflows.
+    outputs: dict
+        A dictionary mapping output nodes to corresponding outflows.
     """
 
     def __init__(self, *args, **kwargs):
@@ -59,12 +70,27 @@ class Node(Entity):
             edge.output = o
 
 
+_deprecation_warning = (
+    "Usage of {} is deprecated. Use oemof.network.Node instead."
+)
+
+
 class Bus(Node):
-    pass
+    def __init__(self, *args, **kwargs):
+        warnings.warn(
+            _deprecation_warning.format(type(self)),
+            FutureWarning,
+        )
+        super().__init__(*args, **kwargs)
 
 
 class Component(Node):
-    pass
+    def __init__(self, *args, **kwargs):
+        warnings.warn(
+            _deprecation_warning.format(type(self)),
+            FutureWarning,
+        )
+        super().__init__(*args, **kwargs)
 
 
 class Sink(Component):


Test patch:
diff --git a/tests/test_energy_system.py b/tests/test_energy_system.py
index 9af475e..6e602f5 100644
--- a/tests/test_energy_system.py
+++ b/tests/test_energy_system.py
@@ -42,6 +42,30 @@ class TestsEnergySystem:
         assert node2 in self.es.nodes
         assert (node1, node2) in self.es.flows().keys()
 
+    def test_add_flow_assignment(self):
+        assert not self.es.nodes
+
+        node0 = Node(label="node0")
+        node1 = Node(label="node1")
+        node2 = Node(label="node2", inputs={node0: Edge()})
+
+        self.es.add(node0, node1, node2)
+
+        assert (node0, node2) in self.es.flows().keys()
+        assert (node1, node2) not in self.es.flows().keys()
+        assert (node2, node1) not in self.es.flows().keys()
+
+        node2.inputs[node1] = Edge()
+
+        assert (node0, node2) in self.es.flows().keys()
+        assert (node1, node2) in self.es.flows().keys()
+        assert (node2, node1) not in self.es.flows().keys()
+
+        node2.outputs[node1] = Edge()
+        assert (node0, node2) in self.es.flows().keys()
+        assert (node1, node2) in self.es.flows().keys()
+        assert (node2, node1) in self.es.flows().keys()
+
     def test_that_node_additions_are_signalled(self):
         """
         When a node gets `add`ed, a corresponding signal should be emitted.
diff --git a/tests/test_network_classes.py b/tests/test_network_classes.py
index 507dfd4..6b49a58 100644
--- a/tests/test_network_classes.py
+++ b/tests/test_network_classes.py
@@ -21,6 +21,8 @@ import pytest
 
 from oemof.network.energy_system import EnergySystem as EnSys
 from oemof.network.network import Bus
+from oemof.network.network import Sink
+from oemof.network.network import Source
 from oemof.network.network import Transformer
 from oemof.network.network.edge import Edge
 from oemof.network.network.entity import Entity
@@ -124,7 +126,7 @@ class TestsNode:
         """
         flow = object()
         old = Node(label="A reused label")
-        bus = Bus(label="bus", inputs={old: flow})
+        bus = Node(label="bus", inputs={old: flow})
         assert bus.inputs[old].flow == flow, (
             ("\n  Expected: {0}" + "\n  Got     : {1} instead").format(
                 flow, bus.inputs[old].flow
@@ -172,7 +174,7 @@ class TestsNode:
     def test_modifying_inputs_after_construction(self):
         """One should be able to add and delete inputs of a node."""
         node = Node("N1")
-        bus = Bus("N2")
+        bus = Node("N2")
         flow = "flow"
 
         assert node.inputs == {}, (
@@ -329,12 +331,23 @@ class TestsEnergySystemNodesIntegration:
         self.es = EnSys()
 
     def test_entity_registration(self):
-        b1 = Bus(label="<B1>")
-        self.es.add(b1)
-        assert self.es.nodes[0] == b1
-        b2 = Bus(label="<B2>")
-        self.es.add(b2)
-        assert self.es.nodes[1] == b2
-        t1 = Transformer(label="<TF1>", inputs=[b1], outputs=[b2])
-        self.es.add(t1)
-        assert t1 in self.es.nodes
+        n1 = Node(label="<B1>")
+        self.es.add(n1)
+        assert self.es.nodes[0] == n1
+        n2 = Node(label="<B2>")
+        self.es.add(n2)
+        assert self.es.nodes[1] == n2
+        n3 = Node(label="<TF1>", inputs=[n1], outputs=[n2])
+        self.es.add(n3)
+        assert n3 in self.es.nodes
+
+
+def test_deprecated_classes():
+    with pytest.warns(FutureWarning):
+        Bus()
+    with pytest.warns(FutureWarning):
+        Sink()
+    with pytest.warns(FutureWarning):
+        Source()
+    with pytest.warns(FutureWarning):
+        Transformer()