Skip to content

Move detectors params handling completely in detectors class - #947

Merged
thehrh merged 5 commits into
masterfrom
detector_params
Jun 12, 2026
Merged

thehrh merged 5 commits into
masterfrom
detector_params

Conversation

@JanWeldert

Copy link
Copy Markdown
Collaborator

This PR

  • resolves Detectors class doesn't update parameters with the same name that are not shared in fit #946
  • streamlines the detectors class test
  • moves the handling of param updates completely in the detectors class. Every time an output is generated, it is checked if a parameter changed. If so the parameters in the individual distribution makers are updated. Each detectors class function now also initializes the params so their changes to the distribution maker params are propagated.

@thehrh thehrh left a comment

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.

As a final remark, if update_param_values_detector should remain (still used a few times in analysis.py after all), it would benefit from a more detailed docstring than

"Modification of the update_param_values function to use with the Detectors class"

, in particular, why it is needed and when to use it (compare explanation in update_param_values).

Comment thread pisa/core/detectors.py Outdated
Comment thread pisa/core/detectors.py Outdated
Comment thread pisa/core/detectors.py Outdated
Comment thread pisa/core/detectors.py Outdated
Comment thread pisa/core/detectors.py
Comment thread pisa/core/detectors.py
Comment thread pisa/core/detectors.py Outdated
Comment thread pisa/core/detectors.py
def test_Detectors(verbosity=Levels.WARN):
from pisa.analysis.analysis import update_param_values_detector

def test_Detectors():

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.

Can you come up with a test which demonstrates what you fixed (not least because the notebook was unable to prevent #946)?

"metadata": {},
"source": [
"When checking the chi2 value from the fitted model, you maybe see that it is around 113, while in the minimizer loop we saw it converged to 116. It is important to keep in mind that in the fit we had extended the metric with prior penalty terms. When we add those back we get the identical number as reported in the fit."
"When checking the chi2 value from the fitted model, you maybe see that it is around 111, while in the minimizer loop we saw it converged to 114. It is important to keep in mind that in the fit we had extended the metric with prior penalty terms. When we add those back we get the identical number as reported in the fit."

@thehrh thehrh Jun 8, 2026 •

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.

Relating to this notebook, it really doesn't need cells such as these, which were originally taken from the public 3-yr example notebook:

The two pipelines are quite different, with most complexity in the neutrino pipeline, that has several Stages and free parameters

or

While the muon pipleine is rather simple

etc.

Basically, all the content that has nothing to do with the Detectors functionality should be removed. Instead, just include a link to the public 3-yr example notebook at the top (for details about how pipelines work).

Also, you could add more instructions and hints with respect to working with the Detectors class in this notebook (setting parameters correctly, when are changes propagated, ...). A more tutorial-like notebook would be really useful to include in the sphinx docs (https://icecube.github.io/pisa/docs/tutorials.html).

@thehrh thehrh added this to the 4.3 milestone Jun 9, 2026
@JanWeldert
JanWeldert requested a review from thehrh June 12, 2026 14:33
@thehrh

thehrh commented Jun 12, 2026 •

Copy link
Copy Markdown
Collaborator

Are you done? I could live with leaving the update_param_values_detector request and possibly some more Detectors usage examples to a follow-up PR.

@thehrh

thehrh commented Jun 12, 2026 •

Copy link
Copy Markdown
Collaborator

How would you proceed with #932? If I understand correctly, this will now render unnecessary the workaround you described there, because the state of the attached ParamSet would be compared to that with which the Detectors instance was initialised at some point before the minimisation starts/before the first template is computed?

@JanWeldert

Copy link
Copy Markdown
Collaborator Author

resolves #932

@thehrh
thehrh merged commit d6b8a0b into master Jun 12, 2026
2 checks passed
@thehrh
thehrh deleted the detector_params branch June 12, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants