astropy/astropy — pull request #2398 by mdboom (2014-05-01 01:20:41+00:00)
Title: Different input formats for Angle confuse unit parsing

Both of the following work fine:
```
In [17]: Angle(['1d'])
Out[17]:

In [18]: Angle([1 * u.deg])
Out[18]:
```

But if I mix the two formats I get a `No unit specified` exception:

```
In [11]: Angle(['1d', 1 * u.deg])
ERROR: UnitsError: No unit specified [astropy.coordinates.angle_utilities]
---------------------------------------------------------------------------
UnitsError Traceback (most recent call last)
in ()
----> 1 Angle(['1d', 1 * u.deg])

/Users/aldcroft/git/astropy/astropy/coordinates/angles.pyc in __new__(cls, angle, unit, dtype, copy)
116 except ValueError as e:
117 raise TypeError(str(e))
--> 118 angle, unit = cls._convert_string_array_to_angles(angle, unit)
119
120 self = super(Angle, cls).__new__(cls, angle, unit, dtype=dtype,

/Users/aldcroft/git/astropy/astropy/coordinates/angles.pyc in _convert_string_array_to_angles(cls, angle, unit)
159 otypes=[np.float_])
160
--> 161 return convert_string_to_angle_ufunc(angle), determined_unit[0]
162
163 @staticmethod

/Users/aldcroft/anaconda/envs/astropy-ape5/lib/python2.7/site-packages/numpy/lib/function_base.pyc in __call__(self, *args, **kwargs)
1570 vargs.extend([kwargs[_n] for _n in names])
1571
-> 1572 return self._vectorize_call(func=func, args=vargs)
1573
1574 def _get_ufunc_and_otypes(self, func, args):

/Users/aldcroft/anaconda/envs/astropy-ape5/lib/python2.7/site-packages/numpy/lib/function_base.pyc in _vectorize_call(self, func, args)
1636 for _a in args]
1637
-> 1638 outputs = ufunc(*inputs)
1639
1640 if ufunc.nout == 1:

/Users/aldcroft/git/astropy/astropy/coordinates/angles.pyc in convert_string_to_angle(x)
146
147 def convert_string_to_angle(x):
--> 148 ang, new_unit = util.parse_angle(six.text_type(x), unit)
149 if determined_unit[0] is None:
150 determined_unit[0] = new_unit

/Users/aldcroft/git/astropy/astropy/coordinates/angle_utilities.pyc in parse_angle(angle, unit, debug)
345 string.
346 """
--> 347 return _AngleParser().parse(angle, unit, debug=debug)
348
349

/Users/aldcroft/git/astropy/astropy/coordinates/angle_utilities.pyc in parse(self, angle, unit, debug)
264
265 if unit is None and found_unit is None:
--> 266 raise u.UnitsError("No unit specified")
267
268 return found_angle, found_unit

UnitsError: No unit specified

In [12]:
```