astropy/astropy — pull request #2571 by mhvk (2014-05-28 00:58:53+00:00)
Title: With quantity output, ensure non-quantity input is treated as dimensionless

With current master, output from a `ufunc` to a quantity works for two argument functions, but not for one-argument ones (see below). This PR fixes this, even though it will rarely be used.
```
In [1]: import astropy.units as u, numpy as np

In [2]: s = 1.*u.m

In [3]: np.arctan2(1., 1., out=s)
Out[3]:

In [4]: s
Out[4]:

In [5]: np.arctan(1., out=s)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
----> 1 np.arctan(1., out=s)

/usr/lib/python2.7/dist-packages/astropy/units/quantity.pyc in __array_prepare__(self, obj, context)
200 # the unit the output from the ufunc will have.
201 if function in UFUNC_HELPERS:
--> 202 scales, result_unit = UFUNC_HELPERS[function](function, *units)
203 else:
204 raise TypeError("Unknown ufunc {0}. Please raise issue on "

/usr/lib/python2.7/dist-packages/astropy/units/quantity_helper.pyc in helper_dimensionless_to_radian(f, unit)
94 from .si import radian
95 try:
---> 96 scale = unit.to(dimensionless_unscaled)
97 except UnitsError:
98 raise TypeError("Can only apply '{0}' function to "

AttributeError: 'NoneType' object has no attribute 'to'
```