-
Notifications
You must be signed in to change notification settings - Fork 10
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
Feature/time series load update and sgen update #184
base: main
Are you sure you want to change the base?
Conversation
…ted, wip on batch calc Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
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.
i didn't dig too deep into the code yet but here are some simple remarks to get things started
# Set pandas data | ||
self.pp_input_data = data | ||
self._create_input_data() | ||
elif data_type == "update": | ||
self.pp_update_data = data | ||
self._update_input_data() |
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.
since this function is called _parse_data
, this may not be the right place to actually set
the data. could be out of scope though
Alternatively, maybe it's a good moment to split the (minor) chunks of differences between input_data
, output_data
and update_data
into separate classes
@@ -65,18 +72,21 @@ def _parse_data(self, data: PandaPowerData, data_type: str, extra_info: Optional | |||
Returns: | |||
Converted power-grid-model data |
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.
right now, it always return
s self.pgm_input_data
. I think it should return self.pgm_update_data
when the data_type == "update"
, right?
self.pgm_input_data = {} | ||
self.idx_lookup = {} | ||
self.next_idx = 0 | ||
|
||
# Set pandas data | ||
self.pp_input_data = data | ||
self.pgm_update_data = {} |
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.
nitpick but please keep similar fields close together for readability, e.g.:
self.pgm_input_data = {}
self.pgm_update_data = {}
self.idx_lookup = {}
self.next_idx = 0
@@ -247,7 +257,7 @@ def _extra_info_to_pgm_input_data(self, extra_info: ExtraInfo): # pylint: disab | |||
nan = np.iinfo(dtype).min | |||
all_other_cols = ["i_n"] | |||
for component, data in self.pgm_output_data.items(): | |||
input_cols = power_grid_meta_data["input"][component].dtype.names | |||
input_cols = power_grid_meta_data["input"][component]["dtype"].names |
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.
was this a bug? or a deprecated feature of structured arrays? the original one feels more correct but i could be wrong
const_i_multiplier = self._get_pp_attr("load", "const_i_percent", 0) * scaling * (1e-2 * 1e6) | ||
const_z_multiplier = self._get_pp_attr("load", "const_z_percent", 0) * scaling * (1e-2 * 1e6) |
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.
const_i_multiplier = self._get_pp_attr("load", "const_i_percent", 0) * scaling * (1e-2 * 1e6) | |
const_z_multiplier = self._get_pp_attr("load", "const_z_percent", 0) * scaling * (1e-2 * 1e6) | |
const_i_multiplier = self._get_pp_attr("load", "const_i_percent", 0) * scaling * 1e4 | |
const_z_multiplier = self._get_pp_attr("load", "const_z_percent", 0) * scaling * 1e4 |
or split the coefficients, e.g. (but please clean up a bit by reordening):
const_i_multiplier = self._get_pp_attr("load", "const_i_percent", 0) * scaling * (1e-2 * 1e6) | |
const_z_multiplier = self._get_pp_attr("load", "const_z_percent", 0) * scaling * (1e-2 * 1e6) | |
percent = 1e-2 | |
unit_magnitude = 1e6 | |
scaling *= unit_magnitude | |
const_i_multiplier = self._get_pp_attr("load", "const_i_percent", 0) * percent * scaling | |
const_z_multiplier = self._get_pp_attr("load", "const_z_percent", 0) * percent * scaling |
# Convert it to a list, debugger was complaining | ||
pp_load_ids = list(pp_load_ids) |
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.
why does it need to be a set
in the first place? why not start with a list
? or, if it should be a set
, there's probably a problem somewhere down the line 😄
For instance, i don't know if _get_timeseries_load_ids
wants a list
as input. If so, either start with a list
or convert to list
there.
If you really need the uniqueness feature of set
, as well as use the list
output in multiple places, then please update the comment instead
|
||
self.pgm_update_data["sym_load"] = pgm_load_profile | ||
|
||
# |
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.
todo: remove before merge (you can always re-add later)
# pylint: disable-msg=too-many-locals | ||
def _pp_update_sgens(self): # pragma: no cover |
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.
todo: probably a good idea to split in separate functions if it complains about this
(note: i understand why it's still in there, so no hurry. i just add this comment for reference)
@@ -134,6 +139,7 @@ def test_parse_data__extra_info( | |||
fill_pp_extra_info_mock.assert_called_once_with(extra_info=extra_info) | |||
|
|||
|
|||
@pytest.mark.xfail() |
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.
todo: i'm guessing you just haven't updated the test yet, which is fine, hence the todo 😄
Signed-off-by: Laurynas Jagutis <[email protected]>
SonarCloud Quality Gate failed. |
@TonyXiang8787 @Laurynas-Jagutis is this PR still relevant? |
@mgovers we have decided to on hold this one. |
No description provided.