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

refactor/doc: make curtailment more robust, update README #100

Merged
merged 3 commits into from
Apr 9, 2020

Conversation

danielolsen
Copy link
Contributor

Purpose

Correct fragility of _check_resource_in_scenario() to input type.

What is the code doing

New tests are added in test_curtailment.py to pass all 'supported' input types to calculate_curtailment_time_series: set, list, and tuple, and to pass differently ordered lists and tuples. Initially, these tests fail.

In curtailment.py, _check_resource_in_scenario() is refactored to check for the set of resources being a subset of scenario.state.get_grid().plant['type'].unique(), ignoring all ordering.

In README.md, update the call signatures of postreise/analyze functions to match the reorganization that was done in #88.

@danielolsen danielolsen added the bug Something isn't working label Apr 9, 2020
@danielolsen danielolsen requested review from rouille and BainanXia April 9, 2020 20:34
gentypes_in_grid = scenario.state.get_grid().plant['type'].unique()
if resources not in gentypes_in_grid:
gentypes_in_grid = set(scenario.state.get_grid().plant['type'].unique())
if not set(resources) <= gentypes_in_grid:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another option here is to use Set.issubset(Iterable), which could handle any iterable type of inputs automatically, i.e. set(resources).issubset(scenario.state.get_grid().plant.type). I'm happy with current implementation as well.

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.

All tests passed. More tests, more robust.

@danielolsen danielolsen merged commit 2a7f9c4 into develop Apr 9, 2020
@danielolsen danielolsen deleted the make_check_resource_more_robust branch April 9, 2020 21:25
@ahurli ahurli mentioned this pull request Mar 16, 2021
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.

2 participants