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

Let Node(label=name) == name #37

Closed
wants to merge 1 commit into from
Closed

Conversation

p-snft
Copy link
Member

@p-snft p-snft commented Nov 8, 2023

As we require labels to be unique anyway, we could use them for def __eq__(self, other):. This should then allow to have Nodes as the keys in the solph result dict but to also just give the label.

node0 = Node(label="label_0")
test_dict = {node0: 5}
assert test_dict[node0] == 5
assert test_dict["label_0"] == 5

Are there arguments against this? (At least if #35 gets merged, we already assure that the energy system will not contain multiple nodes with the same label multiple times. So, two nodes are the same if they have the same label.)

@p-snft p-snft self-assigned this Nov 8, 2023
@p-snft p-snft added the enhancement New feature or request label Nov 8, 2023
@p-snft p-snft added this to the v1.0.0 milestone Nov 8, 2023
@p-snft
Copy link
Member Author

p-snft commented Nov 13, 2023

As there might be nodes with the same label belonging to different graphs, the might lead to undefined behaviour. Thus, I will retract this suggestion.

@p-snft p-snft closed this Nov 13, 2023
@p-snft p-snft deleted the feature/entity_equals_label branch November 22, 2023 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant