fix: enable AC investment costs to be calculated for branches connected to new buses#462
Merged
danielolsen merged 3 commits intodevelopfrom Apr 24, 2021
Merged
Conversation
BainanXia
reviewed
Apr 23, 2021
BainanXia
reviewed
Apr 23, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
I found a new bug, where if you try to calculate AC investment costs for a scenario where at least one branch is connected to a new bus, we run into an error. Traceback, using Scenario 3828:
This commit fixes that bug.
What the code is doing
Inside the
if len(bus_fix_index_all) > 0:block, we are attempting to fix any buses that are not in the bus-to-region mapping dataframebus_reg, or whose locations don't match what's in the previous mapping file (e.g. in case we changed the locations of some buses since the last time we generated the cached bus-to-region mappings).However, in the current code, we are only successfully updating bus-to-region mappings for buses whose locations don't match, but not adding new mappings for new buses. The first commit fixes this issue, by separating the new mappings into corrections (which are modified in-place) and additions (which are appended). The second commit refactors the code slightly for clarity. The third commit makes use of the index-name-preserving append method (from #450). All commits will be squashed down before merging.
Testing
After the first commit, tested successfully on Scenario 3828. For the second and third commit, I manually tested to make sure that the values returned remained the same.
Time estimate
15 minutes. The functional change is very simple, but if you want to trace through the variable renaming and refactoring, you have to take the time to decipher the current code, where the variable naming is not especially intuitive.