astropy/astropy — pull request #1839 by mhvk (2013-11-29 05:49:57+00:00)
Title: Table with generalized columns subclasses -- another (better?) attempt

I made another attempt at getting `Column`'s to hold `Quantity` and other `ndarray` subclasses, one which I think is mostly complementary to @taldcroft's #1833, as I on purpose did not (yet) include `Time` here. It is also simpler than my other attempt (#1835), a bit more in the spirit of #1583, in that the essence is to create a new `Column` subclass whose other subclass is `Quantity` (or whatever; note that I did not adjust `MaskedColumn` yet, since we do not really have other `MaskedArray` subclasses yet). The new piece is that new subclasses are defined automatically (with `Quantity` input -> `QuantityColumn` class, etc.)

With this PR:
```
from astropy.table import Table; from astropy.coordinates import Angle, Longitude, Latitude; import numpy as np; import astropy.units as u
q = np.arange(3.)*u.m
l = Longitude(np.arange(10.,13.), 'deg')
b = Table([q,l], names=['q','l'])

In [7]: print(b)
q l
----- ---------
0.0 m 10d00m00s
1.0 m 11d00m00s
2.0 m 12d00m00s

In [8]: b['q'], b['l']
Out[8]:
(QuantityColumn name='q' unit='m' format=None description=None>

)

In [9]: b['q'] += 1.*u.cm

In [10]: print(b)
q l
------ ---------
0.01 m 10d00m00s
1.01 m 11d00m00s
2.01 m 12d00m00s
```