-
Notifications
You must be signed in to change notification settings - Fork 1
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
Only initialize runner once in NeymanConstructor #103
Changes from 1 commit
568004e
4ba6d88
7b4f38f
cfc7b3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,10 @@ def submit( | |
if os.path.splitext(limit_threshold)[-1] != ".json": | ||
raise ValueError("The limit_threshold file should be a json file.") | ||
|
||
# initialize the runner | ||
script = next(self.computation_tickets_generator())[0] | ||
runner = self.initialized_runner(script, pop_limit_threshold=True) | ||
|
||
# calculate the threshold, iterate over the output files | ||
threshold = cast(Dict[str, Any], {}) | ||
for runner_args in self.merged_arguments_generator(): | ||
|
@@ -187,15 +191,22 @@ def submit( | |
) | ||
|
||
# update poi according to poi_expectation | ||
runner_args["statistical_model_args"].pop("limit_threshold", None) | ||
runner = Runner(**runner_args) | ||
expectation_values = runner.model.get_expectation_values( | ||
**{**nominal_values, **generate_values} | ||
) | ||
# in some rare cases the poi is not a rate multiplier | ||
# then the poi_expectation is not in the nominal_expectation_values | ||
component = self.poi.replace("_rate_multiplier", "") | ||
poi_expectation = expectation_values.get(component, None) | ||
if runner.input_poi_expectation: | ||
poi_expectation = generate_values.get("poi_expectation") | ||
# nominal_values are passed to update_poi to update the poi | ||
# like wimp_mass, livetime, etc. | ||
generate_values = runner.update_poi( | ||
runner.model, self.poi, generate_values, nominal_values | ||
Comment on lines
+199
to
+200
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this won't work with static parameters. That was the entire point of the previous PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran it quickly and yes, this crashes if you have static parameters (as it should). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The recent commit 7b4f38f makes the PR compatible with static parameters. |
||
) | ||
else: | ||
expectation_values = runner.model.get_expectation_values( | ||
**{**nominal_values, **generate_values} | ||
) | ||
# in some rare cases the poi is not a rate multiplier | ||
# then the poi_expectation is not in the expectation_values | ||
# in these cases we only assign None to poi_expectation | ||
component = self.poi.replace("_rate_multiplier", "") | ||
poi_expectation = expectation_values.get(component, None) | ||
poi_value = generate_values.pop(self.poi) | ||
|
||
# make sure no poi and poi_expectation in the hashed_keys | ||
|
@@ -214,8 +225,8 @@ def submit( | |
) | ||
hashed_keys = { | ||
"poi": self.poi, | ||
"nominal_values": nominal_values, | ||
"generate_values": generate_values, | ||
"nominal_values": deepcopy(nominal_values), | ||
"generate_values": deepcopy(generate_values), | ||
"confidence_level": confidence_level, | ||
} | ||
threshold_key = deterministic_hash(hashed_keys) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just "if poi_expectation" in generate_values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also be fine. What is the benefit?