astropy/astropy — pull request #1564 by nden (2013-10-12 16:16:47+00:00)
Title: Fitters return a copy of the model

As discussed in #1330 and #979 fitters should return a modified copy of the model instead of modifying it in place.
This PR is not completed yet but I am submitting it to get opinions on a side effect which breaks the current constraints API.

As a reminder of how the constraints code evolved, initially constraints were attributes on fitters but it was felt largely that it would be better to move them to models and in particular be attributes on parameters (`~astropy.modeling.parameters.Parameter`) which is what they currently are. This facilitates interactive use of `~astropy.modeling`, so it's possible to do something like:

```
gauss = models.Gaussian1DModel(amplitude=10, mean=3, stddev=1)
gauss.stddev.min = 1
gfit = fitting.NonLinearLSQFitter(gauss)
gfit(x, y)
gauss.stddev.min = 2
gfit(x,y)
```
The second call to `gfit` will pick up the change in the constraints.

In this PR fitters make a copy of the model and don't hold a reference to the initial model any more so the above code does not work as expected. This means that changing the constraints interactively will have to use the copy of the model too.

```
gfit.model.stddev.min = 2
```

Since this is an end user API change I wanted to see how others felt about it.