eteq/astropy — pull request #13 by mhvk (2014-04-23 05:07:24+00:00)
Title: Trial implementation of __repr__ and __str__

To have `repr` and `str` produce at least something, I combined the looks of `recarray` and `Quantity`, a bit like happens now for `EarthLocation`. The current implementation is far from fast & perfect, but suffices perhaps to show what it will look like (also, it seems impossible to raise an issue, so one has to do a PR...).

cc @eteq, @taldcroft, @astrofrog, @Cadair, @adrn

In action (note how the angle units get lost; bit of a pity, but not essential for now):
```
In [1]: from astropy.coordinates.representation import *

In [2]: import numpy as np; import astropy.units as u

In [3]: c = SphericalRepresentation(np.arange(0, 360, 90) * u.deg, np.arange(-90, 90, 45) * u.deg, np.arange(1,5)*u.pc)

In [4]: c
Out[4]:

In [5]: c.to_cartesian()
Out[5]:

In [6]: c.represent_as(UnitSphericalRepresentation)
Out[6]:

In [7]: c.represent_as(CylindricalRepresentation)
Out[7]:

n [8]: c.represent_as(PhysicsSphericalRepresentation)
Out[8]:

In [9]: print(c)
[(0.0, -90.0, 1.0) (90.0, -45.0, 2.0) (180.0, 0.0, 3.0) (270.0, 45.0, 4.0)] (deg,deg,pc)

In [10]: print(c.represent_as(UnitSphericalRepresentation))
[(0.0, -1.5707963267948966) (1.5707963267948966, -0.7853981633974483)
(3.141592653589793, 0.0) (4.71238898038469, 0.7853981633974483)] rad
```