def distance(self, new_distance):
if not isinstance(new_distance, u.Quantity):
self._distance = new_distance * 1000. * u.pc
else:
if new_distance.unit.physical_type != 'distance':
TypeError('Wrong type of new_distance!')
if (new_distance.unit == "pc") or (new_distance.unit == "kpc"):
self._distance = new_distance
else:
raise u.UnitsError(
'Allowed units for Lens distance are "pc" or "kpc"')
评论列表
文章目录