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

Allow declaring and retriveing names associated with draws in the Scenario class #1452

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tbhallett
Copy link
Collaborator

@tbhallett tbhallett commented Aug 2, 2024

Fixes #1451

This line can be added to the Scenario class:

    def draw_names(self, draw_number) -> str:
        return list(self._scenarios.keys())[draw_number]

and in the analysis script, the draw_names can be retrieved using

extract_draw_names(results_path)

Optionally, the existing extract_parameters function can index the parameters being changes by these same draw names.

@tbhallett tbhallett requested a review from tamuri August 2, 2024 17:48
@@ -234,6 +234,11 @@ def draw_parameters(self, draw_number, rng):
"""
return None

def draw_name(self, draw_number) -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do draw names need to come from a function i.e. need to be calculated in some interesting way? Instead, you could add a line in the scenario's constructor, such as:

self.draw_names = ['one', 'two', 'three']

or

self.draw_names = [f'draw_{i}' for i in range(0,10)]

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They don't need to come from a function, I don't think..... But, I thought it was good to follow the pattern established by draw_parameters(self, draw_number, rng), and also this gives most flexibility.

Most often we define a dictionary of the form:

self._scenarios = {'my_scenario_name': {'ModuleName': {'parameter_name': new_parameter_value}}} 

and so it's true that we could have instead in the __init__:

self.draw_names = list(self._scenarios.keys()

@tbhallett tbhallett requested a review from tamuri October 17, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready to merge
Development

Successfully merging this pull request may close these issues.

Save a label for the draw when using Scenario class
2 participants