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

Refactor element containers in Store #356

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

daniel-thom
Copy link
Collaborator

This is an intermediate PR that should not be merged to master. Many more changes are required. I want to make sure you agree with the first set of changes before proceeding.

Take a look at tests/test_store.py for example uses. I fixed the OpenDSS reader but nothing else.

raise NotImplementedError(
"Build function must be implemented by derived classes"
)
"""Optional function to perform post-init construction after an element
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this change. It is a potential point of disagreement.

self.model[node].nominal_voltage = new_value

node_model = None
for model_type in (Node, Load, PowerSource, Capacitor):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a better pattern than this. This was just to make some tests pass.


def replace_kth_switch_with_recloser(self):
"""
For every feeder, replace a switch downstream of the feeder head with a recloser. The depth of the switch is chosen at random with the distribution [0.7,0.25, 0.05]
"""
np.random.seed(0)
# Loop over the objects
for elt in self.model.models:
# TODO: Tarek, can we specify a type?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this one

# Get the from node
if hasattr(obj, "from_element") and obj.from_element is not None:
node_from_object = self.model[obj.from_element]
for obj in self.model.iter_elements(Line, lambda x: x.nominal_voltage is None):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tarekelgindy Let me know what you think of the filter function. You may or may not find it more readable. It removes some of the heavily-nested blocks.

@@ -13,6 +13,8 @@
import numpy as np


from ditto.store import ElementNotFoundError
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that most of the changes in this file are due to removals of indentation.

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

Successfully merging this pull request may close these issues.

1 participant