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
Add write function to FitResult
#5258
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5258 +/- ##
==========================================
- Coverage 75.27% 75.25% -0.03%
==========================================
Files 234 234
Lines 35148 35168 +20
==========================================
+ Hits 26458 26465 +7
- Misses 8690 8703 +13 ☔ View full report in Codecov by Sentry. |
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.
Thanks @Astro-Kirsty, could you add a test for that ?
How do you produce the bad outpout for total_stat ?
I tried with the analysis_2 toturial and the output seems fine.
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.
I have some minor comments. This PR is globally ready to be merged! Thanks you a lot
Just as a comment, some information stored as data are in fact metadata, e.g.
I propose to fix that later on a separated PR about metadata handling. |
Using this code snippet The print is fine, but then the output in the yaml file is not |
Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
7e370c9
to
f5739d4
Compare
Signed-off-by: Quentin Remy <quentin.remy@mpi-hd.mpg.de>
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.
Thanks @Astro-Kirsty, the yaml file written by the test seems ok.
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.
Thnaks @Astro-Kirsty . My review is a bit late.
Some general comments:
- What about a read method? The point of the write method is to be able to retrieve the result later.
- I think we would need a more generic scheme to be able to handle different steps. I would suggest to implement a
to_dict()
method on theFitStepResult
. - There is code duplication between this
write
andto_yaml
methods and those implemented onModels.write
andDatasets.write
. Maybe we should improvegammapy.utils.scripts.write_yaml
to support all these cases.
full_output=full_output, overwrite_templates=overwrite_templates | ||
) | ||
|
||
return { |
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.
Maybe start with optimize_results
then covariance_result
and finally models
.
|
||
return { | ||
"models": models_dict, | ||
"covariance_result": { |
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.
What happens if covariance has not been run?
|
@registerrier Do we really need a read method for objects that are only used for diagnostics and not configuration ? |
This PR is to include a write function in the
FitResult
and partly resolves #5154The following is implemented
#5255 (comment)
Not sure why 'total_stat' is not saving as a value but instead like this