Skip to content

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

Merged
danielolsen merged 3 commits intodevelopfrom
make_check_resource_more_robust
Apr 9, 2020
Merged

refactor/doc: make curtailment more robust, update README#100
danielolsen merged 3 commits intodevelopfrom
make_check_resource_more_robust

Conversation

@danielolsen
Copy link
Copy Markdown
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 BainanXia and rouille 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
Copy Markdown
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
Copy Markdown
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