astropy/astropy — pull request #1914 by nden (2013-12-18 17:04:52+00:00)
Title: Separate optimization from statistic

This PR separates optimization from statistic and allows creating fitters by combining optimizers and statistic functions.

Because of the many changes It's probably best to review this by looking at the entire files (fitting.py, optimizers.py, statistic.py) and not the diffs in the PR.

I am proposing that the name of the fitter is constructed from the names of the optimizer and the statistic, so some existing fitters have been renamed:

`SLSQPFitter` --> `SLSQPLSQFitter`
`NonLinearLSQFitter` --> `LevMarLSQFitter`

Statistics are implemented as functions (but can be any callable) and are stored currently in `~astropy.modeling.statistic.py`. Currently there are two `leastsquare` and (following @cdeil's example in a different PR) `cash`. The input to the statistic functions is `func(measured_values, evaluated_values, weights)`.

Optimization methods are stored in `~astropy.modeling.optimizers.py`. They are implemented as classes in order to store additional information about the optimization properties but can be any callable.

Dealing with model's constraints has been moved to optimizers. Some methods of the old `Fitter` class were made functions.

I still need to add tests for the new fitter and possibly write a custom_fitter. Other than that I have pretty much completed what I had in mind and would appreciate comments on overall design, statistic implementation, names and any other improvements.