astropy/astropy — pull request #3072 by Cadair (2014-11-05 17:52:28+00:00)
Title: Add a new decorator for functions accepting quantities.

This is something that has cropped up in a discussion inside SunPy about how to verify the inputs on functions which expect quantities.

We often have the situation where the input to the function is a quantity (or many) and because it is representing something physical, it is expected to be convertible to a specific (usual) unit. i.e. convertible to degrees for a on sky angle. This decorator will check all arguments to a function and make sure that they are convertible to the specified units and raise a nice error if they are not.

The decorator expects a number of arguments equal to the number of arguments to the function and any keyword arguments that need to be verified.

i.e.

```python
@quantity_input(u.deg, u.deg, None, distance=u.km)
def myfunction(ra, dec, someflag, distance=1*u.au):
ra.unit == u.deg
dec.unit == u.deg
````

p.s. I am aware that this is not the place for this function in the code base and it needs tests etc, but I thought I would first solicit opinions about if it belongs in astropy _at all_.