Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@reneeotten
Copy link
Contributor

This PR contains a few commits as part of an attempt to make full use of pytest to run the tests. It increases the coverage in test_ampgo.py, test_basinhopping.py, test_brute.py and test_itercb.py.

As an outcome of the increased coverage a few oversights were found (incidentally?) all introduced by me ;) Anyway, the following fixes were made:

  1. logic in show_candidates is now explicit
  2. the estimation of the covariance matrix is only attempted when the fit finished correctly and not when it was aborted.

The code would probably benefit from some re-factoring, but that should be done at the same time as we address the _calculate_statistics function. For example, right now result.residual is set when the fit is aborted, but still needs to be calculated if it finishes normally. In many instances we do a check like if not result.aborted and then calculate/fill in the MinimizerResult attributes. After that we calculate the statistics, which should be done regardless, and then -only if not aborted- we should calculate the covariance matrix. There are a bit too many if-statements involved there, but I cannot get easily a consistent way of doing this for all solvers. So my changes for now work as intended, and making big changes just before a release does not seem smart... Ideally, we would tackle this once the test coverage has increased and we are not as likely to miss potential issues.

Finally, I updated the dependencies in .travis.yml to add numdifftools and install emcee only for version == latest. These dependencies and pytest are installed with pip because conda does not have consistent versions available for all Python versions we test.

@newville
Copy link
Member

@reneeotten This all looks good to me. I agree with the approach of calculating covariance if the fit is not aborted. I think the branches are not too excessive -- it really is slightly complicated, but that's OK. A refactor of the statistics calcs is probably a good idea soon, but let's give ourselves time to play with that.

OK to merge this?

OK to release as 0.9.12?

@reneeotten
Copy link
Contributor Author

@newville, yes to both questions. I will continue to work on the tests with respect to fully using pytest and increase the coverage. But it's kind of busy so it probably will take some time tom complete...

@newville
Copy link
Member

@reneeotten Great! merging this. Will tag 0.9.12 soon...

@newville newville merged commit 1268177 into lmfit:master Nov 29, 2018
@reneeotten reneeotten deleted the pytest branch November 29, 2018 03:14
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.

2 participants