astropy/astropy — pull request #1203 by adonath (2013-06-24 17:46:06+00:00)
Title: Simplified implementing new models #980 

Hi everyone,

during the last week I've worked on simplifying the implementation of new models.
So far this only works with 1D models, but I'd like to get some feedback, before I continue working on this.

At first I've introduced a new Parametric1DModel class, which is the base class for all
parametric 1D models. It mainly implements the appropriate __call__() function and does some "bookkeeping" in the constructor, to check whether analytical derivatives are implemented etc. The model parameters are currently set automatically by getting the
arguments from the model's constructor. I wanted a way to avoid setting all model parameters "by hand", as the Parameter class may still change.

Furthermore I've made a few changes in the models deriv() function. So far it used a dictionary and list comprehension for the derivatives, which I changed to an ordinary list. This which should be faster. Scipy's lsqr fitter has an option "col_deriv" which can be set, when the derivatives are given across the columns. So I removed the transpose step in deriv(). Finally I've changed the function call of deriv(), so that no dummy variables are necessary. It is only important that the order of parameters is consistent in the model definition. I hope that I've not overlooked something, which made this things necessary. But so far all tests passed.

I've implemented a few simple new models. Among a "Custom1DModel" which can be used to create new models "on the fly" just from a function. This may be useful when
working with astropy interactively.

Since this is my first "real" pull request, I would be happy for any kind of feedback! Thanks in advance!