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

fix: create copy of bus table before modifying within get_bus_demand function #484

Merged
merged 1 commit into from
May 20, 2021

Conversation

danielolsen
Copy link
Contributor

@danielolsen danielolsen commented May 20, 2021

Pull Request doc

Purpose

When performing the get_bus_demand function, avoid modifying the bus table of the Grid that is passed as input. This is not a problem when we call scenario.get_bus_demand() on a Scenario in Analyze state, since that method passes a fresh copy of the grid so the grid associated with the scenario doesn't change, but it's still an unintuitive behavior in case anyone uses the lower-level function.

Testing

Before:

>>> from powersimdata import Scenario
>>> from powersimdata.input.input_data import get_bus_demand
>>> scenario = Scenario(599)
>>> grid = scenario.get_grid()
>>> len(grid.bus.columns)
19
>>> get_bus_demand(scenario.info, grid)
>>> len(grid.bus.columns)
21

After:

>>> from powersimdata import Scenario
>>> from powersimdata.input.input_data import get_bus_demand
>>> scenario = Scenario(599)
>>> grid = scenario.get_grid()
>>> len(grid.bus.columns)
19
>>> get_bus_demand(scenario.info, grid)
>>> len(grid.bus.columns)
19

Time estimate

2 minutes.

@danielolsen danielolsen self-assigned this May 20, 2021
Copy link
Collaborator

@BainanXia BainanXia left a comment

Choose a reason for hiding this comment

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

Agree.

@danielolsen danielolsen merged commit d656b60 into develop May 20, 2021
@danielolsen danielolsen deleted the daniel/get_bus_demand_copy branch May 20, 2021 22:24
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.

4 participants