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

Detector class bug fixes #743

Merged
merged 39 commits into from
Jun 2, 2023
Merged

Detector class bug fixes #743

merged 39 commits into from
Jun 2, 2023

Conversation

JanWeldert
Copy link
Collaborator

Updating the detectors class to PISA4 didn't work as I thought. So here are some bug fixes that hopefully will resolve the issues. It is mostly about updating parameter values for the different DistributionMakers that represent the detectors.

@BenSmithers
Copy link
Member

Was it that the parameters weren't updating at all for one of the distribution makers? I might've been running into the same bug! I can look over this

if isinstance(params,Param): params = ParamSet(params)

for distribution_maker in self.distribution_makers:
ps = deepcopy(params)
Copy link
Member

Choose a reason for hiding this comment

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

Does deepcopy need to be used here? As I understand, it's probably to protect the internal Params whenever what's passed to this method is changed later on, but it messes with DerivedParams in a weird little way where they lose references to the original Params they depend on.

I'm confident I could set it up to update those references when this copy happens, but I thought I'd check to see if there was a specific reason this was implemented as-is!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think deepcopy is needed here because the params set is changed afterwards to pass it to the distribution maker but we don't want the detectors class param set to be changed

@@ -2518,6 +2566,8 @@ def _minimizer_callable(self, scaled_param_vals, hypo_maker, data_dist,
scaled_param_vals = np.where(flip_x0, 1 - scaled_param_vals, scaled_param_vals)
# Set param values from the scaled versions the minimizer works with
hypo_maker._set_rescaled_free_params(scaled_param_vals) # pylint: disable=protected-access
if hypo_maker.__class__.__name__ == "Detectors":
update_param_values_detector(hypo_maker, hypo_maker.params.free) #updates values for ALL detectors
Copy link
Member

Choose a reason for hiding this comment

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

One more question - does update_param_values_detector need to be called every minimizer step? It looks like that could be rather expensive since it also makes calls back to init_params, and the free parameters should already be updated here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is needed to update the parameters for all distribution makers

@LeanderFischer
Copy link
Collaborator

Everyone happy with this or are more eyes on this needed?

@JanWeldert JanWeldert changed the title Detector class big fixes Detector class bug fixes Jun 1, 2023
@philippeller philippeller self-requested a review June 2, 2023 08:33
@philippeller
Copy link
Collaborator

i think this is ready

@LeanderFischer LeanderFischer merged commit 41c0e89 into icecube:master Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants