3030signed_dms_tuple = namedtuple ('signed_dms_tuple' , ('sign' , 'd' , 'm' , 's' ))
3131
3232
33- class Angle (u .Quantity ):
33+ class Angle (u .SpecificTypeQuantity ):
3434 """
3535 One or more angular value(s) with units equivalent to radians or degrees.
3636
@@ -83,6 +83,7 @@ class Angle(u.Quantity):
8383 `~astropy.units.UnitsError`
8484 If a unit is not provided or it is not an angular unit.
8585 """
86+ _equivalent_unit = u .radian
8687 _include_easy_conversion_members = True
8788
8889 def __new__ (cls , angle , unit = None , dtype = None , copy = True ):
@@ -111,21 +112,9 @@ def __new__(cls, angle, unit=None, dtype=None, copy=True):
111112 angle .dtype .kind not in 'SUVO' )):
112113 angle = [Angle (x , unit , copy = False ) for x in angle ]
113114
114- self = super (Angle , cls ).__new__ (cls , angle , unit , dtype = dtype ,
115+ return super (Angle , cls ).__new__ (cls , angle , unit , dtype = dtype ,
115116 copy = copy )
116117
117- if not isinstance (angle , Angle ):
118- self ._unit = cls ._convert_unit_to_angle_unit (self .unit )
119- if not self .unit .is_equivalent (u .radian ):
120- if self .unit is u .dimensionless_unscaled :
121- raise u .UnitsError ("No unit was given - "
122- "must be some kind of angle" )
123- else :
124- raise u .UnitsError ("Unit {0} is not an angle"
125- .format (self .unit ))
126-
127- return self
128-
129118 @staticmethod
130119 def _tuple_to_float (angle , unit ):
131120 """
@@ -140,16 +129,12 @@ def _tuple_to_float(angle, unit):
140129 else :
141130 raise u .UnitsError ("Can not parse '{0}' as unit '{1}'"
142131 .format (angle , unit ))
143-
144132 @staticmethod
145133 def _convert_unit_to_angle_unit (unit ):
146134 return u .hourangle if unit is u .hour else unit
147135
148- def __quantity_subclass__ (self , unit ):
149- if unit .is_equivalent (u .radian ):
150- return Angle , True
151- else :
152- return super (Angle , self ).__quantity_subclass__ (unit )[0 ], False
136+ def _set_unit (self , unit ):
137+ super (Angle , self )._set_unit (self ._convert_unit_to_angle_unit (unit ))
153138
154139 @property
155140 def hour (self ):
@@ -258,8 +243,7 @@ def to_string(self, unit=None, decimal=False, sep='fromunit',
258243 if unit is None :
259244 unit = self .unit
260245 else :
261- unit = u .Unit (unit )
262- unit = self ._convert_unit_to_angle_unit (unit )
246+ unit = self ._convert_unit_to_angle_unit (u .Unit (unit ))
263247
264248 separators = {
265249 None : {
0 commit comments