Skip to content

Commit

Permalink
Add warning for experimental node access API
Browse files Browse the repository at this point in the history
  • Loading branch information
p-snft committed Jan 11, 2024
1 parent e246c86 commit 5e58e31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/oemof/network/energy_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import blinker
import dill as pickle

from oemof.tools import debugging

from oemof.network.groupings import DEFAULT as BY_UID
from oemof.network.groupings import Entities
from oemof.network.groupings import Grouping
Expand Down Expand Up @@ -195,6 +197,11 @@ def groups(self):

@property
def node(self):
msg = (
"The API to access nodes by label is experimental"
" and might change without prior notice."
)
warnings.warn(msg, debugging.ExperimentalFeatureWarning)
return self._nodes

@property
Expand Down
8 changes: 8 additions & 0 deletions tests/test_energy_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ def test_add_nodes(self):
assert node2 in self.es.nodes
assert (node1, node2) in self.es.flows().keys()

def test_node_access_warning(self):
node_label = "label"
self.es.add(Node(node_label))
with pytest.warns(
match='API to access nodes by label is experimental'
):
_ = es.node[node_label]

def test_add_flow_assignment(self):
assert not self.es.nodes

Expand Down

0 comments on commit 5e58e31

Please sign in to comment.