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: ensure that get_bus_demand works in Create state #422

Merged
merged 3 commits into from
Mar 19, 2021

Conversation

danielolsen
Copy link
Contributor

@danielolsen danielolsen commented Mar 19, 2021

Purpose

Fixes a couple of bugs when trying to get bus_demand from a Scenario in Create state. Closes #421.

What the code is doing

  • test_create.py adds a test that initially fails.
  • In create.py, we ensure that the scenario_info gets updated before we call get_bus_demand.
  • In input_data.py, we ensure that we only try to apply demand for the zones that are in this particular Grid.

Testing

The automated tests don't cover this, because getting the demand profiles requires ssh, but you can check that tests pass locally using python -m pytest.

Time estimate

5 minutes.

@danielolsen danielolsen added the bug Something isn't working label Mar 19, 2021
@danielolsen danielolsen self-assigned this Mar 19, 2021
@@ -149,6 +149,7 @@ def get_bus_demand(self):

:return: (*pandas.DataFrame*) -- data frame of demand (hour, bus).
"""
self._update_scenario_info()
Copy link
Collaborator

Choose a reason for hiding this comment

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

It makes sense. I am confused to why it was working before without the update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get_demand uses get_profile which uses self.builder.demand, but get_bus_demand passes self.scenario_info without updating self.scenario_info with what we're setting in the builder.

Copy link
Collaborator

Choose a reason for hiding this comment

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

When the bug has been introduced because get_bus_demand was working originally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did we test it in Create state after #388?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably not but I thought this was a feature you were using before creating each scenario. That's why I am surprised you just found the bug now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, this method was not part of my usual scenario setup process. REISE.jl does the same thing within the Julia code though. This feature was mostly being used for scenarios in Analyze state.

bus = grid.bus
demand = InputData().get_data(scenario_info, "demand")[bus.zone_id.unique()]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice safeguard

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.

Good catch!

@danielolsen danielolsen merged commit 0662862 into develop Mar 19, 2021
@danielolsen danielolsen deleted the daniel/create_get_bus_demand branch March 19, 2021 14:26
danielolsen added a commit that referenced this pull request Apr 7, 2021
…s_demand

fix: ensure that get_bus_demand works in Create state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

get_bus_demand cannot be called using Scenario in create state
3 participants