astropy/astropy — pull request #2718 by mhvk (2014-07-10 12:04:21+00:00)
Title: Ensure in-place ops on Angles with non-angle result do not corrupt the instance

Currently, for an inplace operation on an Angle, an exception is raised if the result unit is not an angle unit, but this happens after the instance has been corrupted (see below). This PR solves this by checking an output instance is of the right class for the result unit.
```
In [1]: import astropy.units as u, numpy as np; from astropy.coordinates import Angle, Longitude, Latitude

In [2]: a = Angle(60., u.deg)

In [3]: np.cos(a, a)
...
UnitsError: Given unit is not convertible to an angle

In [4]: a
Out[4]:
```

With this PR:
```
In [1]: import astropy.units as u, numpy as np; from astropy.coordinates import Angle, Longitude, Latitude

In [2]: a = Angle(60., u.deg)

In [3]: np.cos(a, a)
...
TypeError: Cannot store output with unit '' from cos function in instance. Use instance instead.

In [4]: a
Out[4]:
```