Skip to content

Conversation

@GernotMaier
Copy link
Contributor

Improve model parameter overwrite function with an explicit flat_dict statement to avoid being flooded by warnings like

WARNING::model_parameter(l519)::overwrite_parameters::Parameter MSTS-05 not found in model MSTS-12, cannot overwrite it.

(note the error in the warning).

Changes also test values for 'changes' to lists, as discussed here

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the overwrite_parameters method in the model parameter handling code by adding an explicit flat_dict parameter to distinguish between flat parameter dictionaries and nested telescope-specific dictionaries. This prevents incorrect warnings when overwriting parameters from file-based configurations that contain parameters for multiple telescopes.

Changes:

  • Added flat_dict parameter to overwrite_parameters() method to properly handle both flat and nested dictionary formats
  • Updated all direct calls to overwrite_parameters() with flat_dict=True where flat dictionaries are used
  • Changed parameter values in test data from string format to list format for clarity

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/simtools/model/model_parameter.py Added flat_dict parameter to overwrite_parameters() method to distinguish between flat and nested dictionary structures; added debug logging
src/simtools/visualization/plot_psf.py Updated call to overwrite_parameters() to include flat_dict=True
src/simtools/ray_tracing/psf_parameter_optimisation.py Updated call to overwrite_parameters() to include flat_dict=True
tests/unit_tests/visualization/test_plot_psf.py Updated mock assertion to expect flat_dict=True parameter
tests/unit_tests/ray_tracing/test_psf_parameter_optimisation.py Updated mock assertion to expect flat_dict=True parameter
tests/unit_tests/model/test_model_parameter.py Updated test calls to include flat_dict=True where appropriate
tests/resources/info_test_model_parameter_changes.yml Changed parameter values from string format to list format for better clarity
docs/changes/2003.maintenance.md Added changelog entry describing the improvement

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@GernotMaier GernotMaier changed the title Overwrite fix warning Overwrite model parameters: fix warning Jan 30, 2026
@GernotMaier GernotMaier marked this pull request as ready for review January 30, 2026 13:59
@GernotMaier GernotMaier requested review from EshitaJoshi and tobiaskleiner and removed request for tobiaskleiner January 30, 2026 13:59
Copy link
Collaborator

@EshitaJoshi EshitaJoshi left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@GernotMaier
Copy link
Contributor Author

Thanks - @EshitaJoshi could you do me a favor and solve the conflict in test_plot_psf? That one is new.

@ctao-sonarqube
Copy link

ctao-sonarqube bot commented Feb 2, 2026

@GernotMaier GernotMaier merged commit c98ebcb into main Feb 3, 2026
16 checks passed
@GernotMaier GernotMaier deleted the overwrite-fix-warning branch February 3, 2026 06:20
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.

3 participants