Fix set_source output from save_all #100
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Release Notes
This fixes a bug whereby the
save_all
function would not create the necessaryset_source()
line. This does not fix all cases, but it does the simple PHA case such asThis is bug #97.
It also ensures that files created by
save_all
can be run using IPython's%run
directive, by explicitly importing thesherpa.astro.ui
module.The
sherpa.astro.ui.save_session
function has been removed: this was never documented and was never meant to be released as it did not work correctly. This cleanup also removes thesherpa.ui.utils.loggable
class.Details
This is an extremely simplified version of PR #98 which only addresses one problem, and does not add a test suite. It is however very easy to review.
Test
With the simple test case
then with the
master
branchand with this PR
The difference in the output is
Note it now contains a
set_source
statement.WIth the new output I can restore it and get the same statistic value back:
If you tried this with the original output then - as well as having to ensure Sherpa was imported - the
calc_stat()
call will fail because there's no source model set up (due to the missingset_source
line):