Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning at the same labeled components #52

Open
eliftu opened this issue Mar 27, 2025 · 1 comment
Open

Warning at the same labeled components #52

eliftu opened this issue Mar 27, 2025 · 1 comment

Comments

@eliftu
Copy link

eliftu commented Mar 27, 2025

Labels need to be unique. it will leads failure, when there is the same labeled components. Check when adding.

@p-snft
Copy link
Member

p-snft commented Mar 27, 2025

I think something like this would solve the problem:

class EnergySystem:
    (...)
    def add(self, *nodes):
        """Add :class:`nodes <oemof.network.Node>` to this energy system."""
        new_nodes = {node.label: node for node in nodes}
        if self._nodes.keys().isdisjoint(new_nodes.keys()):
            self._nodes.update(new_nodes)
        else:
            common_labels = self._nodes.keys() & new_nodes.keys()
            raise ValueError(f"EnergySystem already contains Node(s) labeled {common_labels}.")
        for n in nodes:
            self.signals[type(self).add].send(n, EnergySystem=self)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants