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
Tweak test for issue 717 to be repeatable #802
Conversation
I've pulled this out of #754 since it is a small standalone update, unrelated to |
For completeness, I have also run the new version of the test in CIAO 4.12 and confirm that with the power-law model the
|
The reason for this PR (that is, making this yrdy "repeatable" by enforcing the method/stat/...) was found in developing #754 - where a run of
presumably because a previous test had changed the statistic to |
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.
By default, the levmar
optimization method will be used but I guess it doesn't hurt to have it just in case we ever change the default opt method (although I verified that neldermead
does give the same answer)
ui.set_method('levmar')
Thanks for the review. I'll look at rebasing this to fix whatever the conflict is. |
The test did not set up the method and statistic, and this caused problems when the order of tests was changed (when running in parallel) and an unwanted change to the default statistic caused the test to fail. This commit now tries to ensure a clean session and forces a particular optimised and statistic.
b7d4496
to
2961ae7
Compare
@dtnguyen2 - I've had to rebase this because I made almost the same in a different PR (#772, adding XSPEC 12.11.0 support), so this makes the changes even smaller (now just ensuring the test gets cleaned before/after running and that the method is set). |
Codecov Report
@@ Coverage Diff @@
## master #802 +/- ##
==========================================
- Coverage 62.98% 62.96% -0.02%
==========================================
Files 70 70
Lines 24315 24315
Branches 3509 3509
==========================================
- Hits 15315 15311 -4
- Misses 7862 7866 +4
Partials 1138 1138
Continue to review full report at Codecov.
|
The apparent failure of the codecov/project run just indicates some "randomness" in our tests. The pragbayes.py module tests have decreased, even though none of the tests in this PR make use of the code in sherpa.astro.sim.pragbayes. In this case a test no-longer raises a LimitError in some Monte-Carlo run so we don't cover the error case any more. It's nothing to do with this PR. |
Summay
Make a test more robust.
Details
The following is from before #772 was merged (adding XSPEC 12.11.0), which ended up making most of the changes that were in this PR.
While working on other issues I found that the fix for issue #717 - added in #728 - was not sufficiently isolated, so that adding other tests (or running tests in parallel) could cause this test to fail because of changes to the Sherpa state made by other tests.
There are two commits that
a) ensure that the test is run with a "known" environment (e.g. statistic)
b) switches from an APEC model (from the XSPEC library) to a power-law model (from Sherpa's model library), which means the test can be run without XSPEC, and has benefits because the powerlaw model is a much-better description of the data, and is also much-less likely to change over time (the APEC model depends on external data tables and other things that have been known to change between XSPEC releases)
As the original problem (#717) was to do with evaluating any model - rather than a particular model - the change from APEC to powerlaw shouldn't change the validity of the test.