-
Notifications
You must be signed in to change notification settings - Fork 151
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
No deepcopy when renumbering components #916
Conversation
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.
For this one I cannot immediately confirm the change is ok.
The function _renumber_components
does not have a bang, so it should be non-destructive for the input arguments. By changing the value of comp["index"]
without copying it, some of the data in comp_dict
has been changed.
So I am suspecting this function should be renamed _renumber_components!
and then it should be confirmed that all existing uses are still OK when this function is destructive.
That is true 🤔 I believe an in-place, destructive version would serve us better indeed. No need for a new dictionary, we can update the existing one in-place, which would also make things more explicit to the user.
I did a repo-wide search of
If you want to get rid of the non-destructive version, it can be deprecated and removed in a later version. |
If that is the case, I am fine to change this to the destructive version along with the function name change. I don't mind removing the original. The change is "non-breaking" to external users because this function is indicated as internal use only and not exported. |
* Improve performance of calc_connected_components (#914) --------- Co-authored-by: mtanneau3 <[email protected]> * Add in-place conversion to basic data format (#915) * Add in-place conversion to basic data format * Add unit test for in-place make_basic_network --------- Co-authored-by: mtanneau3 <[email protected]> * No deepcopy when renumbering components (#916) * No deepcopy when renumbering components * In-place _renumber_components and unit tests * Fix typo --------- Co-authored-by: mtanneau3 <[email protected]> Co-authored-by: Carleton Coffrin <[email protected]> * add notes to changelog and prep for release * Update psse parser for 3winding transformers (#917) * fix psse parser 3 winding tranformers * update readme * add note to changelog and readme * fix quote counting check in psse parser --------- Co-authored-by: Mathieu Tanneau <[email protected]> Co-authored-by: mtanneau3 <[email protected]> Co-authored-by: Rahmat Heidari <[email protected]>
Motivated by #913.
This PR removes an internal
deepcopy
while re-indexing components in_renumber_components
, thus reducing time and memory allocations.1354_pegase
2869_pegase
9241_pegase
13659_pegase
and corresponding profile of
make_basic_network(data)
wheredata = pglib("9241_pegase")