-
Notifications
You must be signed in to change notification settings - Fork 36
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
base: master
Are you sure you want to change the base?
Conversation
266cdef
to
3684223
Compare
raise NotImplementedError( | ||
"Build function must be implemented by derived classes" | ||
) | ||
"""Optional function to perform post-init construction after an element |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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.